Hi Chris,
You need to use a while loop to fetch all of the records returned in the
SELECT statement in PHP, as follows:
<?php
$db = mysql_connect("host", "user", "pwd");
mysql_select_db("dbname",$db);
$result = mysql_query("SELECT * FROM NAMES_TBL",$db);
while ($row = mysql_fetch_array ($result)) {
printf("DBID: %s<br>\n", $row["DBID"];
printf("First Name: %s<br>\n",$row["FIRST_NAME"];
printf("Last Name: %s<br>\n", $row["LAST_NAME"];
}
?>
----- Original Message -----
From: "Admin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 06, 2003 16:47
Subject: query only returns one row
>
>
> Hi,
>
> I finally established a connection to my db after I realized that it was
> located in a different directory than that which I kept placing my php
> files. As some would say, "D'OH!"
>
> The code below is intended to select and display all 1300 names from the
> NAMES_TBL but is only returning the first row. I'm still a bit new to php
> so this is probably something simple - a shove in the right direction
would
> be quite helpful.
>
> thanks!
>
> chris
>
> <?php
> $db = mysql_connect("host", "user", "pwd");
> mysql_select_db("dbname",$db);
> $result = mysql_query("SELECT * FROM NAMES_TBL",$db);
> printf("DBID: %s<br>\n", mysql_result($result,0,"DBID"));
> printf("First Name: %s<br>\n", mysql_result
> ($result,0,"FIRST_NAME"));
> printf("Last Name: %s<br>\n", mysql_result($result,0,"LAST_NAME"));
> ?>
>
> --------------------------------------------------------------------------
-
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php