Have you seen this Twitter Search and Facebook shows most recent tweets/posts count from the database every 10 seconds on top of the page. I had developed like this with jQuery and Ajax. It's simple just 5 lines of code
Example 1
Index.htmlContains javascript and HTML code. Take a look at load("record_cound.php")
<script type="
text/javascript" src="
http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"
></script><script type="
text/javascript"
>var auto_refresh =
setInterval(
function
()
{
$('
#load_tweets').
load('
record_count.php').
fadeIn("
slow");
},
10000);
// refresh every 10000 milliseconds
<body>
<div id="
load_tweets"
> </div>
</body>
</script>
record_count.phpJust printing "9lessons | programming" every 10 seconds
<?php
echo "9lessons | Programming blog..............";
?>
Example 2
index.phpContains PHP code you have to pass the search box value twitter.com/search?q="some thing" to $search_word in facebook pass the user id or user session value.
<script type="
text/javascript" src="
http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"
></script><script type="
text/javascript"
>var auto_refresh =
setInterval(
function
()
{
$('
#load_tweets').
load('
record_count.php?q=<?php echo $search_word;?>').
fadeIn("
slow");
},
10000);
// refresh every 10000 milliseconds
<body>
<div id="
load_tweets"
> </div>
</body>
</script>
record_count.phpCounting tweets/posts from the database.
<?php
$search_word=
$_GET['
q'];
$sql =
mysql_query("
Select id form Messages where message LIKE '%$search_word%'");
$record_count=
mysql_num_rows($sql);
//Display count.........
echo $record_count;
?>