Returning Column Headings From Mysql Table
Posted: Fri Oct 02, 2009 10:43 am
Hi all
I'm quiet new to php and mysql, i do have some basic knowledge of the two and of programming in general.
i have a database with several tables.
i can successfully display data, but i would like the columns to have headings
the code im using is at the bottom
attached is a screen shot of the current output.
also if anyone could point me in the direction of a really goo guide to php i would appreciate it. i currently have a couple of pdfs but im finding parts of them difficult to understand....... something like a free dummies guide would be good i guess....
thanks
Adam
// Collects data from "players" table
$data = mysql_query("SELECT * FROM players,pdetails WHERE players.ID = pdetails.ID")
or die(mysql_error());
Print "<table border cellpadding=3>";
// puts the "players" info into the $info array
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th><b>ID:</b> </th> <td>".$info['ID'] . "</td>";
Print "<th><b>Name:</b> </th> <td>".$info['Name'] . "</td>";
Print "<th><b>Num:</b> </th> <td>".$info['Num'] . "</td>";
Print "<th><b>Pos:</b> </th> <td>".$info['Pos'] . "</td>";
Print "<th><b>DOB:</b> </th> <td>".$info['DOB'] . "</td>";
Print "<th><b>Height:</b> </th> <td>".$info['Height'] . "</td>";
Print "<th><b>Weight:</b> </th> <td>".$info['Weight'] . "</td>";
Print "<th><b>Shoots:</b> </th> <td>".$info['Shoots'] . "</td></tr>";
}
Print "</table>";
I'm quiet new to php and mysql, i do have some basic knowledge of the two and of programming in general.
i have a database with several tables.
i can successfully display data, but i would like the columns to have headings
the code im using is at the bottom
attached is a screen shot of the current output.
also if anyone could point me in the direction of a really goo guide to php i would appreciate it. i currently have a couple of pdfs but im finding parts of them difficult to understand....... something like a free dummies guide would be good i guess....
thanks
Adam
// Collects data from "players" table
$data = mysql_query("SELECT * FROM players,pdetails WHERE players.ID = pdetails.ID")
or die(mysql_error());
Print "<table border cellpadding=3>";
// puts the "players" info into the $info array
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th><b>ID:</b> </th> <td>".$info['ID'] . "</td>";
Print "<th><b>Name:</b> </th> <td>".$info['Name'] . "</td>";
Print "<th><b>Num:</b> </th> <td>".$info['Num'] . "</td>";
Print "<th><b>Pos:</b> </th> <td>".$info['Pos'] . "</td>";
Print "<th><b>DOB:</b> </th> <td>".$info['DOB'] . "</td>";
Print "<th><b>Height:</b> </th> <td>".$info['Height'] . "</td>";
Print "<th><b>Weight:</b> </th> <td>".$info['Weight'] . "</td>";
Print "<th><b>Shoots:</b> </th> <td>".$info['Shoots'] . "</td></tr>";
}
Print "</table>";