WeirdMystery Posted June 2, 2010 Share Posted June 2, 2010 The following query in the code returns mysql_num_rows as 20 however, it doesn't go even once through the loop. Could anyone tell me what I'm doing wrong? <?php include("default.php"); if(isset($_POST['lastid'])) { $lastid=mysql_real_escape_string($_POST['lastid']); $preq = mysql_query("SET @rank=0"); $q = mysql_query("SELECT @rank:=@rank+1 AS rank, id, content, likes FROM `makeyourown` ORDER BY `likes` DESC LIMIT $lastid, 20") or die(mysql_error()); while ($r = mysql_fetch_assoc($q)); { echo $r[rank]; echo "<div class=\"stuff_container_right\">\n"; echo "<div class=\"c2\"></div>\n"; echo "<div class=\"c1\"></div>\n"; echo "<div class=\"stuff\">\n"; echo "<a href=\"viewlikepage.php?id=" . $r[id] . "\">" . $r[content] . "</a><span style=\"float: right;\">" . number_format($r[likes]) . " Likes</span>" ; echo "</div>\n"; echo "<div class=\"c1\"></div>\n"; echo "<div class=\"c2\"></div>\n"; echo "</div>\n"; $idddd = $r[rank]; } echo "<div id=\"more" . $idddd . "\" class=\"stuff_container_right\">\n"; echo "<div class=\"c2\"></div>\n"; echo "<div class=\"c1\"></div>\n"; echo "<div class=\"stuff\">\n"; echo "<a id=\"" . $idddd . "\" class=\"more\" href=\"#\">Load More Pages</a>"; echo "</div>\n"; echo "<div class=\"c1\"></div>\n"; echo "<div class=\"c2\"></div>\n"; echo "</div>\n"; echo "</div>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/203699-weird-query-problem/ Share on other sites More sharing options...
mrMarcus Posted June 2, 2010 Share Posted June 2, 2010 where are you using mysql_num_rows? Link to comment https://forums.phpfreaks.com/topic/203699-weird-query-problem/#findComment-1066934 Share on other sites More sharing options...
WeirdMystery Posted June 3, 2010 Author Share Posted June 3, 2010 Nevermind Guys, I'm super stupid. I put a semi-colon right after the declaration of the loop. Link to comment https://forums.phpfreaks.com/topic/203699-weird-query-problem/#findComment-1066943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.