This is the code to display query result in a table...





<?
include "connection.php";

$query="select * from contactlist";
$qr=mysql_query($query);
if($qr==false){
echo ("Query cannot be executed!<br>");
echo (mysql_error());
}
else{
?>
<table border=1>
<tr>
<td>Bil</td><td>Name</td><td>Email</td>
<td>DOB</td><td>Gender</td><td>State</td>
</tr>
<?
$color="#00CCFF";
while($rekod = mysql_fetch_array($qr)){
//alternate color for row
if ($color=="#00CCFF"){
$color="#FFCC00";
}else{
$color="#00CCFF";
}

?>
<tr bgcolor="<?=$color?>" >
<td><?=$rekod["ID"]?></td>
<td><?=$rekod["nama"]?></td>
<td><?=$rekod["email"]?></td>
<td><?=$rekod["dob"]?></td>
<td><?=$rekod["gender"]?></td>
<td><?=$rekod["state"]?></td>
</tr>
<?
}//end while
?>
</table>
<?
}//end else
?>

Popular Posts