create an html table from mysql db

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

jhaustein
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Oct 17, 2002 6:23 am

create an html table from mysql db

Postby jhaustein » Thu Oct 17, 2002 6:31 am

hey

i´ve an mysql db with following structure

tag________obst_____name
01.01.02___apfel _____hans
02.01.02___birne _____peter
01.01.02___birne _____kai
03.01.02___banane ___kai

and now i will create an html table with the following structure

______01.01.__02.01.__03.01.
apfel___hans
birne___kai___peter
banane______________kai

can you help me by solving this prob.
:-) jörg

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Thu Oct 17, 2002 10:35 am

$query=mysql_query("SELECT * FROM `table`");

echo "<table width=800 border=0>";
while($data=mysql_fetch_array($query))
{
echo"<tr><td>$data[1]</td><td>$data[2]</Td><td>$data[3]</td></tr>";
}
echo "</table>";

jhaustein
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Oct 17, 2002 6:23 am

create an html table from mysql db

Postby jhaustein » Thu Oct 17, 2002 10:44 pm

hey thanks for answer but it doesn´t solve my prob. the script does not create the table what i´m looking for

:-) jörg

Jay

Postby Jay » Fri Oct 18, 2002 1:16 am

We will help you with your scripts, but not write them for you! Pejone's solution is the standard method.

Begin your table as normal (heading cells etc), then call the results as a row. For every row print a row in your table containing the results, and then end the table, voila!

If you can't structure the query correctly, then try to make it into an array and use this array to generate the table. It's all about learning how to use loops and generate a table row each time!


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron