This is not really a MySQL question so much as it is a PHP/HTML question, but it's a quick answer.

Replace
echo "<option>".$rows['lastname']
With
echo "<option value='".$rows['chairid']."'>".$rows['lastname']

On the next page, $_REQUEST['person'] contains the selected chairid.

Martin Toombs wrote:
Sorry if this is simple, but I'm a fairly new user and it's got me stumped.

Using PHP and MySql; I want to look up a specific record from a table of people by using a select query to populate a PHP <select> </select> statement. I can do it with one field, but I need to do it with more than one field since I have people with the same last name.

This populates my option box quite well:

<?php
$sql = "SELECT * FROM chairs order by lastname";
$result = mysql_query($sql);
echo "<tr><td align='right'><b>Chairman's Name:</b></td><td align='left'>
<select name='person'>";
while ($rows = mysql_fetch_array($result)){
echo "<option>".$rows['lastname'].", ".$rows['firstname']." ".$rows['chairid']."</option>";
}//end while
echo "</select></td></tr>";


?>

It gives me a "Smith, John 42" to select, with 42 being the chairid (index field)

I need to know how to use this to pick a specific record up for editing.

I appreciate any help.




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to