Forum Moderators: coopster

Message Too Old, No Replies

How to echo all post submitted by an user

         

impact

4:52 pm on Oct 17, 2009 (gmt 0)

10+ Year Member



Hello,
I am trying to make a script that will check through a mysql table and print all post, submitted by a particular user.

This is all i could do. The problem is that, the while loop thing is not correct, can some please point out where I am going wrong?

Any help will be appreciated.

<?php
session_start();
print "<table width='450' border='0'>";
print "<tr>";
print "<td width='103'>Oneword</td>";
print "<td width='337'>Post</td>";
print "</tr>";

include ("secure/db.php");
// Get email id of the player
$email = $_SESSION['email'];

// Get total number of vovabulary
$query = mysql_query("SELECT * FROM post WHERE email = '$email'");
$row=mysql_num_rows($query);

while($row = mysql_fetch_array($query);){
print "<tr>";
print "<td>".$array['serial_number']."</td>";
print "<td>".$array['oneword']."</td>";
print "<td>".$array['post']."</td>";
print "</tr>";
}
mysql_close($con);

print "</table>";
print "</body>";
print "</html>";
?>

[edited by: eelixduppy at 4:59 pm (utc) on Oct. 17, 2009]
[edit reason] disabled smileys [/edit]

rocknbil

2:36 am on Oct 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




while($row = mysql_fetch_array($query);){
print "<tr>";
print "<td>".$array['serial_number']."</td>";
print "<td>".$array['oneword']."</td>";
print "<td>".$array['post']."</td>";
print "</tr>";
}

What is $array, where does that come from? (Rhetorical question . . . ) Try

print "<td>".$row['serial_number']."</td>";
print "<td>".$row['oneword']."</td>";
print "<td>".$row['post']."</td>";

It also looks like you have a misplaced semicolon.

while($row = mysql_fetch_array($query);){

should be

while($row = mysql_fetch_array($query)){

[edited by: eelixduppy at 12:40 am (utc) on Oct. 19, 2009]
[edit reason] disabled smileys [/edit]