Hi,

Can someone help me with writing the script to be able to pull the information from the database without refreshing everytime something new has been added?

My codes at the moment read:

$recentupdates = mysql_query("SELECT * FROM status NATURAL JOIN users WHERE user_id = users.id ORDER BY status_id DESC LIMIT 0, 5");
				$recentnumrows = mysql_num_rows($recentupdates);
				
//Creating While Loop to place all information here
while ($recentrow = mysql_fetch_assoc($recentupdates))
{
   //Adding the Profile picture 
   echo '<span style="color:#999999;font-size:8pt;float:right;">'.$recentrow['date'].'</span>';
	echo '<span><img style="float:left;padding-right:10px;" src="http://www.youthonfire4christ.com/sitepreview/image.php/'.$recentrow['image'].'?width=50&height=50&cropratio=1:1&image=/sitepreview/upload/'.$recentrow['image'].'"></span>';
	echo '<span><strong>'.$recentrow['fname'].' '.$recentrow['lname'].' said: </strong></span><Br />';
	echo '<span>'.$recentrow['status'].'</span><br />';
				
				
//Line Break between each post.
if ($recentnumrows > 1)
{
echo '<p style="clear:left"></p>';
echo '<p style="border-bottom:#cccccc thin solid;padding-bottom:10px;padding-top:10px;"></p>';
					}
				}

the codes works of course. But I want it to be updated automatically when a new post has been made.

Thanks!

** I know we need to use AJAX(JQUERY)** But since im new to AJAX and JQUERY i will need alittle assistants on creating the codes**

Steps:-

1. Get Total number of records in table. (Say: totalRecs = 100)
2. Create a small PHP(say: check.php). Which will compare old total with new total and will echo 'true'/'false'
3. Create a function in javascript(say: getUpdate() ). This method will send an Ajax request with 'totalRecs' as one parameter to above PHP.
4. Once you get the response ('true' OR 'false'), if response is 'true' do another ajax to bring new content and paste it in HTML.

Im kinda new to this... so im not sure as to how to write this... =/ Could u write an example script for me?

I just want it to show the most recent post... (Just like twitter Does)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.