div has id="loaddiv" and new .PHP file needs to be named allposts.php.
here is jQuery function:
Expand|Select|Wrap|Line Numbers
- <script src="http://ajax.googleapis.com/ajax/
- libs/jquery/1.3.0/jquery.min.js"></script>
- <script>
- var auto_refresh = setInterval(
- function()
- {
- $('#loaddiv').fadeOut('slow').load('allposts.php').fadeIn("slow");
- }, 2000);
- </script>
here is script to collect information from database.
Expand|Select|Wrap|Line Numbers
- $sql_mem_data = mysql_query("SELECT id, username, firstname, lastname FROM myMembers WHERE id='$uid' LIMIT 1");
- while($row = mysql_fetch_array($sql_mem_data)){
- $uid = $row["id"];
- $username = $row["username"];
- $firstname = $row["firstname"];
- $lastname = $row["lastname"];
- if ($firstname != "") {$username = "$firstname $lastname"; } // (I added usernames late in my system, this line is not needed for you)
- /////// Mechanism to Display Pic. See if they have uploaded a pic or not //////////////////////////
- $cacheBuster = rand(999999999,9999999999999);
- $ucheck_pic = "members/$uid/image01.jpg";
- $udefault_pic = "members/0/image01.jpg";
- if (file_exists($ucheck_pic)) {
- $blabber_pic = '<img style="border:#7cb815 1px solid; width:40px; height:40px;" src="' . $ucheck_pic . '?' . $cacheBuster . '" width="40px" border="0" />'; // forces picture to be 100px wide and no more
- } else {
- $blabber_pic = "<img style=\"border:#7cb815 1px solid;\" src=\"$udefault_pic\" width=\"40px\" height=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more
- }
- $comentaryDisplayList .= '
- <div id="blablol"><table width="100%" align="center" cellpadding="4" style="border-bottom:#c8eb8c 1px solid;">
- <tr>
- <td width="7%" valign="top"><a href="profile.php?id=' . $uid . '">' . $blabber_pic . '</a>
- </td>
- <td width="93%" style="line-height:1.5em;" valign="top">
- <span class="liteGreyColor textsize9"> ' . $whenComent . ' <a href="profile.php?id=' . $uid . '"><strong>' . $username . '</strong></a> <br />
- via <em>' . $comment_device . '</em></span><br />
- <span class="textsize10"> ' . $comment . '</span>
- </td>
- </tr>
- </table></div>';
- }
Expand|Select|Wrap|Line Numbers
- <div id="loaddiv" style="width:300px; overflow:hidden;">
- <?php echo "$comentaryDisplayList"; ?>
- </div>
Expand|Select|Wrap|Line Numbers
- <?php echo "$comentaryDisplayList"; ?>
Thank You.