[SOLVED] Newbie question about HTML tables and MySQL
Posted: Mon Jul 26, 2004 9:18 am
feyd | Please use
The response comes out
Instead of
Ok I'm sure it is something really simple, but I'm missing it. I'm new, so give me some slack. 
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I am trying to build a simple table to display users and the number of posts to my blog. The problem is that they are on top of each other, rather than side by side. It is creating a new <tr> instead of a new <td>.Code: Select all
<?php
if (! $dbh = mysql_connect('localhost','loginanme','loginpassword')) {
die("Can't connect: ".mysql_error());
}
mysql_select_db('forums');
if (! $result = mysql_query("SELECT username, posts FROM user WHERE posts >= '30' ORDER by posts DESC")) {
die("Can't execute query: ".mysql_error());
}
$rowsFound = @ mysql_num_rows($result);
while ($row=mysql_fetch_array($result))
{
for ($i=0; $i<mysql_num_fields($result); $i++)
echo "\n<table border=1>\n<tr>" .
"\n<td>$row[$i]" . "</td>" .
"\n</tr>";
}
echo "\n</table>\n";
mysql_close($dbh);
?>Code: Select all
User1
2
User2
34
User3
64Code: Select all
User1 2
User2 34
User3 64feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]