How to make a drop-down list next to the field for filling, which will show data from another table and, when pressed, write it into the field?
& lt; form method = "kolstud" action = "kolstud.php" & gt;
& lt; input name = "namebook" ty0or= "int" value = "book name" / & gt;
& lt; input name = "FIOstud" type = "int" value = "Student name" / & gt;
& lt; input type = "submit" name = "Submit2" value = "Add" / & gt;
& lt; / form & gt; // fields for data
$ namebook = $ _REQUEST ['namebook'];
$ FIOstud = $ _REQUEST ['FIOstud'];
$ insert = "INSERT INTO` kolstud` VALUES (
(SELECT `idbook` FROM` book` WHERE `name` = '$ namebook'),
(SELECT `idstudent` FROM` student` WHERE `FIO` = '$ FIOstud')
) "; // request to add
Answer 1
& lt; select name = "book" & gt;
& lt; option value = "0" & gt; Select a book & lt; / option & gt;
& lt ;?
$ res = mysql_query ('select `id`,` name` from `books`');
while ($ row = mysql_fetch_assoc ($ res)) {
? & gt;
& lt; option value = "& lt;? = $ row ['id']? & gt;" & gt; & lt;? = $ row ['name']? & gt; & lt; / option & gt;
& lt ;?
}
? & gt;
& lt; / select & gt;
Something like this. Why do you have input type = “int”?
And if you want to make a button like in Joomla, use css to place the text field above the select so that only the arrow sticks out.
Added