Hello,
I wrote some code to make a table using HTML with <th> tags for displaying header in the first row followed by contents of mysql database. Due to while loop the header is displayed everytime the mysql_fetch_assoc fetches stuff from the database. However I want the header to be displayed only once and I want everything in 1 single table. Here is my php code:
<?php
require 'connect.inc.php';
require 'core.inc.php';
$query = "SELECT `id`, `name`,`title` FROM `onwebed_pages` WHERE 1";
if ($mysql_query = mysql_query($query)){
while ($mysql_row = mysql_fetch_assoc($mysql_query)){
echo "
<table frame='border' cellpadding='10' cellspacing='5'>
<col align='left'</col>
<col align='left'</col>
<col align='left'</col>
<tr>
<th>id</th>
<th>Name</th>
<th>Title</th>
</tr>
<tr>
<td>".$mysql_row['id']."</td>
<td>".$mysql_row['name']."</td>
<td>".$mysql_row['title']."</td>
</tr>
</table>";
}
}else{
die(mysql_error());
}
?>