View Full Version : jQuery PHP While() with jQuery? it doesn't show second record!

10-17-2009, 07:11 AM
Hello guys!

My idea is to pull private messages to the user using PHP from MySQL, then when the user click on <div> element, then it should fadeIn() the message for him.

Let's see it in action:

<script type="text/javascript">

$("#msgBox").css('display', 'inline').fadeIn(3000);

// PHP code!
// query to get the messages!
$SQL = mysql_query("SELECT * FROM msg WHERE to_id = '".$userid."' AND `read` = \"0\"")or die(mysql_error());

// loop and pull more msgs !
while($row = mysql_fetch_array($SQL)){
// Only a function to get the username instead of user id! do not see it!
$sender = sender($row["from_id"],$row["to_id"] );
// Out put format!
echo 'From: '.$sender[0].' |,| And To '.$row["to_id"].' |,| subject! is:';

// Subject here! look in it has span id of *SUBJ* !
echo '<span id="subj"><font color="red">'.$row["subj"].'</font></span>';

// The Private message!
echo '<span id="msgBox" style="display:none;">'.$row["msg"].'</span>';


This couldn't work!

it only works with the *FIRST* record of private messages!
But doesn't with the second message!

Help would be appreciated! :)

10-17-2009, 07:17 AM
You need to use an Ajax call or reload the page.

10-17-2009, 07:51 AM
You need to use an Ajax call or reload the page.

Can you please help me with it! I haven't ever deal with ajax call kind of thing!