There is a form of recording. I will arrange the output name in select using this code :.

 <?php include("../bd.php"); connect(); // вывод фио доктора $sotr = mysql_query("SELECT * FROM doctor"); if ($sotr == true) { echo "<select>"; while ($s = mysql_fetch_array($sotr)) { echo "<option>".$s['family']." ".$s['name']." ".$s['patronymic']."</option>"; } echo "</select>"; } else { echo "Сотрудники отсутствуют"; } 

How to write to database selected values ​​in select ?

    1 answer 1

    this

     echo "<select>"; 

    replaced by

     echo "<form action='post_data.php' method='get'><select id='doctorName' name='doctorName'>"; 

    this

     echo "</select>"; 

    replaced by

     echo "<input type='submit' value='Submit'></select></form>"; 

    add file post_data.php with content

     <?php include("../bd.php"); connect(); mysql_query("INSERT INTO doctor_result (name) VALUES ('" . mysql_real_escape_string($_GET['doctorName']) . "')"); ?> 

    where doctor_result is the table you created and having the "name" field

    • But how can I do it if I already have a mold ready? Look - Sasha Vodyanitsky
    • yazh wrote above specifically for your little one ..... but I don’t know the result where to put the yazh .... create a table for this ... (where do you want to keep the doctor chosen from the mold) - Lesiuk Alexey
    • How to add more data to the handler for writing? - Sasha Vodyanitsky
    • all thanks .. figured out - Sasha Vodyanitsky
    • @LesyukAlexey When you write answers, always indicate that it is better to use mysqli extensions or PDO for working with MySQL. And use bind variables. Because the questions already appear "oh, my php has no mysql_ * functions, what to do." - Mike