Jump to content

Weird Query Problem...


WeirdMystery

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.