Topic awaiting preservation: PHP and HTML Select Form Field |
|
---|---|
Author | Thread |
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 11-25-2007 02:08
Hi all, code: //snippet function write_form() { $year_built_min = 1900; $year_built_max = date("Y"); global $PHP_SELF; print '<form method="POST" enctype="multipart/form-data">'; print '<table cellpadding=2 cellspacing=2 border=1>'; print '<tr><td>Year*</td><td>'; print '<select name="autos_yr" size="1">'; foreach (range($year_built_max,$year_built_min) as $year) { print '<option value="'.$year.'">'.$year.'</option>'; } print '</select>'; print '</td></tr>';
|
Bipolar (III) Inmate From: Missoula, MT |
posted 12-08-2007 10:02 |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 12-08-2007 16:04
If I see this correctly, all you need to do is this: code: foreach (range($year_built_max,$year_built_min) as $year) { print '<option value="'.$year.'">'.$year.'</option>'; }
code: ... $year_of_the_record = $mysqlresult["year"]; ... foreach (range($year_built_max,$year_built_min) as $year) { if ($year == $year_of_the_record) print '<option value="'.$year.'" selected="true">'.$year.'</option>'; else print '<option value="'.$year.'">'.$year.'</option>'; }
|
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 12-14-2007 15:57
TB that is exactly what I was looking for!!! Thank you so much. |