Printing a table from mysql
Posted: Mon Oct 19, 2009 12:23 pm
Hello,
Exactly as the subject says. Here is what I did
I have two post bearing the same email ID. My codes prints one of this post twice. Some one please tell me what, where I am going wrong? I would like to print all post in the database matching the email, one after another.
Thank you,
Exactly as the subject says. Here is what I did
Code: Select all
<?php
session_start();
include ("secure/db.php");
// Get email id of the player
$email = $_SESSION['email'];
// Get all user post
$query = mysql_query("SELECT * FROM post WHERE email = '$email'");
//Calculate total number of rows
$row=mysql_num_rows($query);
$post = mysql_fetch_array($query);
$serial_number = $post['serial_number'];
$oneword = $post['oneword'];
$post = $post['post'];
// If there is no previous post
if ($row == 0){
$row = 1;
$serial_number = 1;
$oneword = "You have no words";
$post = "You have no post";
}
?>
Code: Select all
$i = 0;
while($i < $row){
print "<table width='450' border='0' class='table'>";
print "<tr valign='top'>";
print "<td width='108' scope='col'><div align='left'>".$oneword."</td>";
print "<td width='332' scope='col'><div align='left'>".$post."</td>";
print "</tr>";
print "</table>";
$i++;
}Thank you,