El dom, 24-02-2002 a las 17:39, Matthew Darcy escribió:
> Hi,
> 
> I want to create a dropdown list with options from a table.
> 
> ie
> <HTML>
> <BODY>
> 
> <?php
> 
> $sql_select = "select * from dropdown_options";
> $results = mysql_query($sql_select);
> 
> while ($row = mysql_fetch_array($results);
> {
>       echo "<option VALUE=$row["col1"] NAME=option1>"
> }
> 
> </BODY>
> </HMTL>
> 
> I know this is basic but it is to give you an idea of what I want.
> 
> I have tried to find an example of this in the book I am using to learn to
> no result.
> 
> I am guessing this is how it works from the info I have read from the book.
> 
> Can someone put me on the right path.
> 
> Thanks,
> 
> Matt.

With that semi-colon at the end of the while you are doing an empty
loop... so when the script gets to the <option...> stuff... the array is
empty.

I would do something like this:

<HTML>
<BODY>
<select name="myOptions">
<?php
$sql_select = "select * from dropdown_options";
$results = mysql_query($sql_select);

while ($row = mysql_fetch_array($results){
?>        
<option value="<? print $row["id"] ?>"><? print $row["name"] ?></option>
<?
}
?>
</select
</BODY>
</HMTL>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to