joviyach
06-25-2006, 03:23 AM
I have this working sort of, but I still can't figure out why it is skipping the "uniqid" field. Does it not work if the field is an auto_incrementing INT value or something?
Also, where do I add the "form action" elements to this code to allow the user to actually submit after selecting?
<?php
//connect to MySQL
$connect = mysql_connect("localhost","xxx","xxx") or
die ("Could not connect to database.");
//choose the database
mysql_select_db("peoplelist");
//get data from database
$query = mysql_query(
"SELECT `uniqid`,
`firstname`,
`lastname`
FROM `people`
ORDER BY `lastname` ASC"
) or die (mysql_error());
echo "<select name='people'>\n";
while ($data = mysql_fetch_array($query, MYSQL_ASSOC))
{
echo " <option value='{$data['uniqid']}'>{$data['lastname']},
{$data['firstname']}</option>\n";
}
echo "</select>\n";
?>
Also, where do I add the "form action" elements to this code to allow the user to actually submit after selecting?
<?php
//connect to MySQL
$connect = mysql_connect("localhost","xxx","xxx") or
die ("Could not connect to database.");
//choose the database
mysql_select_db("peoplelist");
//get data from database
$query = mysql_query(
"SELECT `uniqid`,
`firstname`,
`lastname`
FROM `people`
ORDER BY `lastname` ASC"
) or die (mysql_error());
echo "<select name='people'>\n";
while ($data = mysql_fetch_array($query, MYSQL_ASSOC))
{
echo " <option value='{$data['uniqid']}'>{$data['lastname']},
{$data['firstname']}</option>\n";
}
echo "</select>\n";
?>