MYSQL TO HTML TABLE

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

MYSQL TO HTML TABLE

Post by Parody »

Ok, here is my problem, I have some infomation in a MYSQL database which I need to display in a HTML table. The only problem is, the amount of data can change, so I can't have a fixed table.

So here is the question:
How do I do it? :lol:

I didn't know where to put this topic so I just plonked it in Miscellaneous :oops:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

It's quite easy actually:

Code: Select all

$result = mysql_query($query)

echo &quote;<table>&quote;;
while($row = mysql_fetch_assoc($result))
{
  echo &quote;<tr><td>$rowїcolumn1]</td><td>$rowїcolumn2]</td>........</tr>&quote;;
}
echo &quote;</table>&quote;;
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

Thanks, I was stuck with the theory more than the actual code, but cool. Thanks :) :) :wink:
Post Reply