Hi there, I can't imagine why the code below still adding 2 instead of 1. Anyone can help? thanks $num_view = "SELECT * FROM forum_thread where tid = '".$_GET['tid']."' LIMIT 1"; $result = mysql_query($num_view); while($view = mysql_fetch_array($result)) { $no_view = $view['views'] + 1; } $views_counter = "UPDATE forum_thread SET views = '$no_view' WHERE tid = '".$_GET['tid']."'"; mysql_query($views_counter); mysql_close(); PHP:
the purpose of this code is to increment thread view count by 1? if so, then just single update query will do the trick as follows. $update_counter = "UPDATE forum_thread SET views = views + 1 WHERE tid = {$_GET['tid']}"; mysql_query($update_counter); PHP: