0

php and mysql form

Hi all, how I can add values ​​in a table to a combo box in html .. eg: the user's table has the id 1,2,3,4 and that using a query, being able to move to a combo box, to make a selection of id?.

Greetings and thank you very much.

2
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by joslup9
0

0. initialise a variable, $options="";
1. retrieve the data with SELECT...
2. set up a loop (while) on the result object
3. concatenate the $options var in the loop, building up the list:

while...
set the $id from the result object
$options .= "\n\t<option value=\"$id\">$id</option>";
..end loop

<select>
echo out the $options
</select>

0

thanks, I is working.
Now, as I can get that data selected to insert into another table.

For example.

$sql="INSERT INTO CARRERA (id,Hora,Ruta,CHOFER_idChofer,BUS_idBUs)
VALUES
('$_POST[id]','$_POST[Hora]','$_POST[Ruta]','$_POST[CHOFER_idChofer]','$_POST[BUS_idBUs]')";

using the POST, I get the value of a textbox. and insert it to my table.
as I do that but in the combo box

Thank you very much for your help

0

using the POST, I get the value of a textbox. and insert it to my table.
how to do that but in the combo box?

Thank you very much for your help

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.