RE: [PHP] mysql_fetch_array()
| From: | Tyler Longren | Date: | Thu, 08 Mar 2001 04:01:55 +0000 |
| Subject: | RE: [PHP] mysql_fetch_array() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42991@lists.php.net to get a copy of this message | ||
<?php
$connection=mysql_connection(...............);
$db=mysql_select_db(.....................);
$sql="select * from my db";
$sql_result=mysql_query($sql,$connection);
print "<table>";
while ($row=mysql_fetch_array($sql_result))
{
print "<tr>";
foreach ($row as $field)
print "<td>$field</td>";
print "<td><a href=\"search.php?ID=$row[ID]\">";
print "Get it";
print "</a></td>";
print "</tr>";
}
print "</table>";
?>
Try that, you tried to call $mysql_query, when you needed to call
mysql_query. In your code, $mysql_query isn't a variable, it's a function
in PHP.
-----Original Message-----
From: Deependra B. Tandukar [mailto:deepndra@icimod.org.np]
Sent: Wednesday, March 07, 2001 9:34 PM
To: php-general@lists.php.net
Subject: [PHP] mysql_fetch_array()
Greetings!
I am using PHP and MySQL in RedHat 6.0.
I have used mysql_fetch_array() to display the datas in web page but all the
columns are printed twice. What can be the wrong with my code:
<?php
$connection=mysql_connection(...............);
$db=mysql_select_db(.....................);
$sql="select * from my db";
$sql_result=$mysql_query($sql,$connection);
print "<table>";
while ($row=mysql_fetch_array($sql_result))
{
print "<tr>";
foreach ($row as $field)
print "<td>$field</td>";
print "<td><a href=\"search.php?ID=$row[ID]\">";
print "Get it";
print "</a></td>";
print "</tr>";
}
print "</table>";
?>
But it works fine with mysql_fetch_row() however it does not pass the pass
the variable ID.
Looking forward to hearing from you.
Warm regards,
DT
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net