I am not sure how to make this code auto refresh every 8 seconds, please can you point me in the right direction or show me a code. CODE: <?php $query = mysql_query("SELECT * FROM users WHERE username='$user' AND admin='1'"); $numrows = mysql_num_rows($query); ?> <li><a href='chat.php'><span>Chat <?php if($numrows == "1"){echo "<b><font color='red'>(!)</b></font>";} ?></span></a></li> Code (markup): Thanks
Why don't you just use a meta refresh? <meta http-equiv="refresh" content="8;URL='chat.php'" /> Code (markup):
I guess you don't have much experience, try w3schools for javascript. I think you should look into ajax also. I would give you the code but since, I'm new it's not letting me paste the code. EDIT - Actually didn't think of that. The person above me just made it a lot easier.
I only want to lead only the code in the starting post, they code is in a div called menu. I know that this requires Ajax but not sure how to to do it
So you want to refresh a particular 'div' after every 8 seconds. you can try this algorithm this is Javascript Code function refreshdiv (){ $.ajax({ url: '', type: 'json', success: function (r) { $('#div_id').html(r.contents); } }); } setInterval(refreshdiv() ,8000); HTML: in place of url, you need to put path of file/function (php) where you perform action and return the values.
SOLVED: var auto_refresh = setInterval( function () { $('#cssmenu').load('lol.php'); }, 5000); // refresh every 5 seconds Code (markup): And then <body onload="auto_refresh()";> Code (markup): This fixed my problem Quote this for best answer!