HTML Form
Posted: Fri Apr 09, 2010 3:49 pm
I have an html form for contact data displays a drop down for state. The rows for the states are loaded in another table (state). When I use the following code to insert a new row, it works just fine.
My problem is when I use this to "update" on another window, the state is updated with the first row of data from the state table. How do I get the form variable to display the value that's currently on the contact row?
CODE--
Thanks
My problem is when I use this to "update" on another window, the state is updated with the first row of data from the state table. How do I get the form variable to display the value that's currently on the contact row?
CODE--
Code: Select all
<td><b>State:</b></td>
<td><select name="state_abbr" >
<?php
$statelink = mysql_connect('localhost', 'id', 'pwd');
//the database that will be used
mysql_select_db('db') or die('An error as occurred.');
$statequery = 'SELECT abbr,name FROM state ORDER BY abbr';
$stateresult = mysql_query($statequery, $statelink);
while($staterow = mysql_fetch_array($stateresult, MYSQL_ASSOC))
{
$statelevel = $staterow['abbr'];
$statename = $staterow['name'];
print("<option value=$statelevel>$statelevel - $statename</option>");
}
?>
</select>
</td>