Re: Mysql & Select Question -- Help needed
| From: | David Robley | Date: | Thu, 09 Nov 2000 07:01:07 +0000 |
| Subject: | Re: Mysql & Select Question -- Help needed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24434@lists.php.net to get a copy of this message | ||
On Thu, 09 Nov 2000, Jeff Lacy wrote:
>
> Hello World,
>
> I have a search page that has a select on it and I would like to have the value with $age
> selected on it. I don't know how to do this, though. I tried this, but it doesn't work.
> Please tell me what I did wrong. Thank you so much everybody! :-)
>
> if ($row_age = @mysql_fetch_array ($result_age))
> { do
> { $select_age .= "\t<option value=\"{$row_age["age_ix"]}\"";
> if ($age == "{$row_age["age_ix"]}") { echo " selected"; } //
> Problem Line?
if ($age == {$row_age["age_ix"]}) { echo " selected"; }
Drop the double quotes around the value and see what happens. Also have a
look at extract which can help to make your code easier to write (and
read). I would actually do all that in a
while ($row_age = mysql_fetch_array($result_age)) {
loop and just echo the select statements; but that's just me :-)
> $select_age .= ">{$row_age["age"]}\n";
> } while($row_age = @mysql_fetch_array($result_age));
> }
>
>
> P.S. Does anyone know of the differences between SQL 7 and mysql? That would be very helpful.
> Thanks again!
>
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA