Jump to content

Paging Question


Zepo.

Recommended Posts

Ok i have paging listing things from a table. I also have it not displaying certain things based on if there is anouther entree in anouther table. This causes paging problems because it will wnd up showing less and less instead having everything fall down.

Example:

 

loop: if(row exists in other table with same id) dont display

 

So this causes the non display ones to count as an entree in the paging.

 

Is there any way to make it check in the loop for the same id in anouther table before outputting?

Link to comment
Share on other sites

This is the function with the loop.

if(!function_exists('print_offers'))
{
function print_offers($userid, $notcompleted=1, $cat, $orderby, $order, $page) {
$limit == 0;
if($order == "DESC" or $order == "ASC"){
$order = $order;
} else{
$order = "ASC";
}

if($orderby == "cash" or $orderby == "dateadded" or $orderby == "votes" or $orderby == "rating" or $orderby == "completed"){
$orderby = $orderby;
} else {
$orderby = "name";
}

if($cat == "CC"){
$query = @mysql_query("SELECT * FROM `mybb_offers` WHERE `cat` ='".$cat."' AND `MID` = 'no'  ORDER BY `".$orderby."` ".$order." LIMIT $page,10");
} else {
$query = @mysql_query("SELECT * FROM `mybb_offers` WHERE `cat` !='CC' AND `MID` = 'no' ORDER BY `".$orderby."` ".$order." LIMIT $page,10");
}
while($row = @mysql_fetch_array($query, MYSQL_ASSOC)) {
if($notcompleted == 1) {
$check = @mysql_fetch_array(@mysql_query("SELECT id FROM `mybb_offerscompleted` WHERE `offerid`='".$row['id']."' AND `userid`='$userid'"), MYSQL_ASSOC);
if(!$check['id']) {
$limit++;
$return = $return."<div class=\"updates_txt_header\">
		<h2 class=\"updates_h2\">";

$stars = showstarts($row[id], "no", "");
if($cat == "1"){
$return = $return.stripslashes($row['cat']).": ".stripslashes($row['name'])." - <a href=\"out.php?id=".$row['id']."\" target=\"_blank\" onclick=\"location.reload(true);\"><span style=\"color:green\">Complete Offer</span></a> - <a href=\"#\" onclick=\"confirmation(".$row['id'].")\"><span style=\"color:red\">Ignore Offer</span></a></h2></div><div class=\"updates_txt\">";
}else{
$return = $return.stripslashes($row['name'])." - <a href=\"out.php?id=".$row['id']."\" target=\"_blank\" onclick=\"location.reload(true);\"><span style=\"color:green\">Complete Offer</span></a> - <a href=\"#\" onclick=\"confirmation(".$row['id'].")\"><span style=\"color:red\">Ignore Offer</span></a></h2></div><div class=\"updates_txt\">";
}

$return = $return."<p><strong><span style=\"color:#000000\">Added on ".date("jS F Y", $row[dateadded])." | ";

$times = @mysql_numrows(mysql_query("SELECT id FROM `mybb_offerscompleted` WHERE offerid='".$row['id']."' AND approved='1'"));
if($times == "" || !$times) { $times = 0;}
if($times != 1) { $return = $return."Completed $times Times | Offer Credit: <span style=\"color:green\">".CentsToDollars($row['cash'])."</span>.<br /></span></p></strong>"; } else {
$return = $return."Completed 1 Time | Offer Credit: <span style=\"color:green\">".CentsToDollars($row['cash'])."</span><br /></p></span></strong>"; 
}
$return = $return."<table><tr><td width=\"120\">";
if($row[imageurl]) {
$return = $return.'<img src="'.$row['imageurl'].'" width="120" height="60" /><br />';
}
$return = $return."$stars</td><td valign=\"top\"><p>".stripslashes($row['description'])."</p></td></tr></table>";

?>

<?php
$return = $return."</div>
	<div class=\"updates_txt_footer\">
</div>";
}


} else {
$return = $return."<tr>";
$return = $return."<td>";
if($row['imageurl']) {
$return = $return.'<img src="'.$row['imageurl'].'" /><br />';
}
$return = $return."Added on <br />".date("jS F Y", $row['dateadded']).".";
$times = $row['completed'];
if($times == "" || !$times) { $times = 0;}
if($times != 1) { $return = $return."<br /><strong><u>Completed $times times.</u></strong>"; } else {
$return = $return."<br /><strong><u>Completed 1 time.</u></strong>"; }

$return = $return."</td>";
$return = $return."<td>";
$return = $return."<h2>".stripslashes($row['name'])."</h2><p>".stripslashes($row[description])."</p>";
$return = $return."<p>For this offer you will earn ".CentsToDollars($row['cash']).". <a href=\"out.php?id=".$row['id']."\" target=\"_blank\" onclick=\"location.reload(true);\">Complete Offer.</a></p>";
$return = $return."</td>";
$return = $return."</tr>";
}
}
$return = $return."</table>";
return $return;
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.