Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Elcosmo code is a good start, but you need to modify it for each query, to list the fields.
I did not have tested this, and written without PHP on hands, but it should adapt itself by fetching a list of the columns first, add a header to the table, and then output the rows:
PHP Code:
<?php mysql_connect(`.`, `.`, `.`); mysql_select_db(database); //Select all items: $query = mysql_query("SELECT * FROM `users`"); $rows = mysql_fetch_object($query);
//open table echo"<table>";
//get the columns name $aryCols=array(); foreach($rows as $key=>$val){ $aryCols[]=$key; }
//print a header in your table echo"<tr>"; foreach($aryCols as $name){ echo html<<< <th>{$name}</th> html; echo "</tr>";
//parse each rows while($obj=foreach($rows as $row)){ echo"<tr>"; //fetch the columm values foreach($aryCols as $name){ echo html<<< <td>{$obj->$name}</td> html; } echo"</tr>"; }
//close table echo"</table>
__________________
Only a biker knows why a dog sticks his head out the window.
|