RE: [PHP] Drop down Menu
| From: | Wilmar Perez | Date: | Tue, 08 Oct 2002 21:00:33 +0000 |
| Subject: | RE: [PHP] Drop down Menu | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119338@lists.php.net to get a copy of this message | ||
This is a function I made which covers my needs. May be of some help for
you. This is a "select" box but I'm sure you can modify it for a combo box.
$form_fiel_name is the name you want the box to have in your web form.
$table is the table from you want to retrieve the information
$field is the specific field from the table
$kind could be simple or multiple
function show_list_field($form_field_name, $table, $field, $kind)
{
$list_result = "";
$list_result .= "<select name=\"".$form_field_name."[]\" size=\"5
\" ".$kind.">";
$query = "select $field from $table";
$result = mysql_query($query) or die($mysql_error());
while($row = mysql_fetch_array($result))
{
$list_result .= "<option value=\"$row[$field]
\">".htmlspecialchars(stripslashes($row["$field"]))."</option>";
}
$list_result .= "</select>";
return $list_result;
}
Hope it helps
*******************************************************
Wilmar Pérez
Network Administrator
Library System
Tel: ++57(4)2105145
University of Antioquia
Medellín - Colombia
2002
*******************************************************