RE: [PHP-WIN] Re: populating
| From: | Sandeep Murphy | Date: | Mon, 11 Feb 2002 15:43:23 +0000 |
| Subject: | RE: [PHP-WIN] Re: populating | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-11961@lists.php.net to get a copy of this message | ||
thnx to all..
got it..:)
-----Original Message-----
From: Nicole Amashta [mailto:430ntr3k@bellsouth.net]
Sent: segunda-feira, 11 de Fevereiro de 2002 15:14
To: php-windows@lists.php.net
Subject: [PHP-WIN] Re: populating
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
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php