getting the data from a drop down menu
Posted: Wed May 25, 2005 2:12 pm
I have a sequence of drop down menus but I don't know how I can store the responses in other variables. Right now the output I'm getting looks like
location1 [status1] [change]
location2 [status2] [change]
location3 [status3] [change]
.
.
.
.
where all the [status] are drop down menus and the [change] is a submit box. I'd like to use the change button to change the status of the location in the mysql database. How can I at least get my hands on the location that they modified and the new status of that location?
location1 [status1] [change]
location2 [status2] [change]
location3 [status3] [change]
.
.
.
.
where all the [status] are drop down menus and the [change] is a submit box. I'd like to use the change button to change the status of the location in the mysql database. How can I at least get my hands on the location that they modified and the new status of that location?
Code: Select all
<?php
$link = @mysql_connect('localhost', 'root', 'password') or
die("e;Could not connect to MySQL"e;);
$db = @mysql_select_db('temp1',$link) or
die("e;Could not select database"e;);
$query = "e;SELECT * FROM table1"e;;
$result = @mysql_query($query,$link) or
die("e;Could not submit query"e;);
$numrows = @mysql_num_rows($result);
for ($i=0; $i<$numrows; $i++)
{
$infov = mysql_fetch_array($result);
print ("e;Location: "e;."e;$infovїlocation]"e;);
echo("e;$i"e;);
dropmenu($infov);
echo('<br>');
}
exit("e;bye"e;);
?>
<?php
function dropmenu($vector)
{
?>
<SELECT NAME="e;state"e; SIZE="e;1"e;>
<OPTION <?php other($vector,1) ?> VALUE="e;1"e;>ACTIVE</OPTION>
<OPTION <?php other($vector,2) ?> VALUE="e;2"e;>BROKEN</OPTION>
<OPTION <?php other($vector,3) ?> VALUE="e;3"e;"e;>PLANNED</OPTION>
</SELECT>
<input type="e;submit"e; value="e;change"e;/>
<?php
echo("e;$vectorїstatus]"e;);
}
?>
<?php
function other($vector,$int)
{
if($vectorїstatus]==$int)
{
echo('selected');
}
}
?>