Re: Failed to query correctly.
| From: | Dobromir Velev | Date: | Tue, 04 Dec 2001 09:13:47 +0000 |
| Subject: | Re: Failed to query correctly. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-14803@lists.php.net to get a copy of this message | ||
Hi,
I just looked over the code I sent and I saw that there is a bug there. Here's the corrected
version. This one is tested and it
works fine
$query="SELECT * from $tbl";
$result=mysql_db_query($db,$query) or mysql_die();
echo "<table>";
while ($line = mysql_fetch_assoc($result)) {
if (!$firstrow){
echo "<tr>";
while(list($col_name, $col_value) = each($line)) {
print "\t\t<td><p align=center>$col_name</p></td>\n";
$firstrow.="\t\t<td><p align=center>$col_value</p></td>\n";
}
echo "</tr>";
echo "<tr>$firstrow</tr>";
}
else{
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/