RE: [PHP-WIN] Retrieve data from MySQL
| From: | Ignatius Teo | Date: | Wed, 26 Jul 2000 04:01:51 +0000 |
| Subject: | RE: [PHP-WIN] Retrieve data from MySQL | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-1319@lists.php.net to get a copy of this message | ||
You need to use a while loop to repeatedly fetch the results of the
associative array returned by mysql_fetch_array.
If you have a look at the PHP doco, the example is:
$result = mysql_db_query("database","select * from table");
while($row = mysql_fetch_array($result)) {
echo $row["user_id"];
echo $row["fullname"];
}
Ignatius
> -----Original Message-----
> From: Dmeles [mailto:dmeles@paraisonet.com.br]
> Sent: Wednesday, 26 July 2000 11:51
> To: php-windows@lists.php.net
> Subject: Re: [PHP-WIN] Retrieve data from MySQL
>
>
> Hi folks;
>
> I'm new in using PHP. I'm a Cold Fusion developer, and I'm
> trying to move to
> PHP.
>
> Please, I'm in a trouble, I'm trying to retrieve data from a
> table using the
> code above:
>
> <?
> mysql_pconnect("localhost")
> or die("Unable to connect to SQL server");
> mysql_select_db("test") or die("Unable to select database");
>
> $query = "SELECT * FROM guests";
> $numguests = mysql_query($query) or die("Select Failed!");
> $numguest = mysql_fetch_array($numguests);
> ?>
>
> But, $numguest, only retrieve one record from the table,
> what should I have
> to do , to get all records from the table????
>
> Thank you very much;
>
> Danilo Meles
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>