Re: populating
| From: | Nicole Amashta | Date: | Mon, 11 Feb 2002 15:14:11 +0000 |
| Subject: | Re: populating | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11959@lists.php.net to get a copy of this message | ||
Here's a simple example:
=====================
## connect to db host and select db ...
$query = "select id,name from table";
if ( $result = mysql_query($query) )
{
if ( ( $numrows = mysql_num_rows($result) ) > 0 )
{
while ( $row = mysql_fetch_array($result) )
{
$id = $row["id"];
$name = $row["name"];
$options .= "<option value=\"$id\">$name</option>";
}
$options = "<select name=\"id\">$options</select>";
}
}
echo $options; #this will print out the select box with data from the
table based on the query.
=====================
Hope this helps. If you have any questions, feel free to ask!
-Nicole Amashta
www.aeontrek.com
===============================
"Sandeep Murphy" <Sandeep.Murphy@oni.pt> wrote in message
news:69E9C8885D77554CAF2A7C5C690F43595B6278@arexcprd01.e3g.pt...
> Hi,
>
> Can anyone pl guide me as to how I can populate a select box in my PHP
using
> the data from a table of an Mysql database..
>
> I can retrieve the data but unable to show that data in the select box...
>
> TIA,
>
> sands