Hi,
The code looks fine to me - it will output all records in the selected table.
I assume that you want to display the field names as a first row. If this is the case
you could use something like this
$query="SELECT * from $tbl";
$result=mysql_db_query($db,$query) or mysql_die();
echo "<table>";
while ($line = mysql_fetch_array($result,MYSQL_ASSOC)) {
if (!$first){
echo "<tr>";
while(list($col_name, $col_value) = each($line)) {
print "\t\t<td><p align=center>$col_name</p></td>\n";
}
echo "</tr>";
$first=1;
}
echo "<tr>";
while(list($col_name, $col_value) = each($line)) {
print "\t\t<td><p align=center>$col_value</p></td>\n";
}
echo "</tr>";
}
echo "</table>";
Hope this helps
Dobromir Velev
Web Developer
http://www.websitepulse.com/
-----Original Message-----
From: Denny <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, December 04, 2001 09:14
Subject: [PHP-DB] Failed to query correctly.
Hi,
I got this problem when i tried to do a sql query and print the ouput. But the script
below always failed to return the first row of
the records. But i do a manual query, i got the results i wanted.
Thanks,
Denny
$query="SELECT * from $tbl ";
$result=mysql_query($query);
while ($line = mysql_fetch_row($result)) {
while(list($col_name, $col_value) = each($line)) {
print "\t\t<td><p align=center>$col_value</p></td>\n";
}
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]