where is the loop?
Posted: Mon Nov 05, 2007 2:23 pm
Hi
the code below is showing the page numbers (from 1 to 42) on the site. but i can't find a loop that is doing this. can you? ( i see the loop that loads the games but not the page nombers. there is a for loop that is closed very soon that i commented)
http://www.thegrandarcade.com/catego...and-Kids-Games
the code below is showing the page numbers (from 1 to 42) on the site. but i can't find a loop that is doing this. can you? ( i see the loop that loads the games but not the page nombers. there is a for loop that is closed very soon that i commented)
http://www.thegrandarcade.com/catego...and-Kids-Games
Code: Select all
<?php
if (is_numeric($cid)){
$sql = mysql_query("SELECT catid, name, keywords, permissions FROM categories WHERE catid = '$cid' && status = '1'");
if (mysql_num_rows($sql) > 0) {
$row = mysql_fetch_array($sql);
$cid = $row['catid'];
$categoryname = $row['name'];
$categorydescription = $row['description'];
$categorykeywords = $row['keywords'];
$cpermissions = $row['permissions'];
} else {
header("Location: ".$siteurl."/");
exit();
}
} else {
header("Location: ".$siteurl."/");
exit();
}
// Display games
function displaygames($cid,$page,$categoryname) {
global $siteurl,$filesperpage,$sefriendly;
$result = mysql_query("SELECT title, icon, iconlocation, fileid, timesplayed FROM files WHERE category = '$cid' && status ='1'");
if (mysql_num_rows($result) == '0') {
echo "There are no files in this category";
} else {
// Get number of pages
$numrows = mysql_num_rows($result);
$offset = ($page - 1) * $filesperpage;
$pagescount = ceil($numrows/$filesperpage);
/*
for ($pagen = 1; $pagen <= $pagescount; $pagen++) {
if ($pagen == $page) {
$nav .= " <b>$pagen</b>";
} else {
if ($sefriendly == '1') {
$nav .= " <a href=\"".categoryurl($cid,$categoryname)."/".$pagen.".html\">".$pagen."</a><br/>";
} else {
$nav .= " <a href=\"".categoryurl($cid,$categoryname)."&page=".$pagen."\">".$pagen."</a>";
}
}
}
*/
if ($page > 1) {
$pagen = $page - '1';
if ($sefriendly == '1') {
$prev = "<a href=\"".categoryurl($cid,$categoryname)."/".$pagen.".html\">< Previous</a>";
} else {
$prev = "<a href=\"".categoryurl($cid,$categoryname)."&page=".$pagen."\">< Previous</a>";
}
} else {
$prev = "";
}
if ($page < $pagescount) {
$pagen = $page + '1';
if ($sefriendly == '1') {
$next = " <a href=\"".categoryurl($cid,$categoryname)."/".$pagen.".html\">Next ></a>";
} else {
$next = " <a href=\"".categoryurl($cid,$categoryname)."&page=".$pagen."\">Next ></a>";
}
} else {
$next = "";
}
// Display page numbers
if ($pagescount > '1') {
echo "<div id='pagenumbers'>".$prev.$nav.$next."</div>";
}
$result2 = mysql_query("SELECT fileid, title, icon, iconlocation, timesplayed FROM files WHERE category = '$cid' && status ='1' ORDER BY title LIMIT $offset, $filesperpage");
$fileinrow="1";
while($row = mysql_fetch_array($result2)) {
$fileid = $row['fileid'];
$filetitle1 = $row['title'];
$fileicon = $row['icon'];
$iconlocation = $row['iconlocation'];
$timesplayed = number_format($row['timesplayed']);
$filetitle = $row['title'];
if (strlen($filetitle) > '17') {
$filetitle = substr("$filetitle",0,17)."..";
}
if ($iconlocation == '1') {
$imageurl = $siteurl."/files/image/".$fileicon;
} else {
$imageurl = $fileicon;
}
if ($fileinrow == '1') {
echo "";
}
?>
<div class="indeximages">
<div align="left"><a href="<?php echo fileurl($fileid,$filetitle1); ?>" target="_self""><img src="<?php echo $imageurl; ?>" alt="<?php echo $filetitle1; ?>, <?php echo $categoryname; ?>" width="140" height="110" /></a><a href="<?php echo fileurl($fileid,$filetitle1); ?>" target="_self"></a><a href="<?php echo fileurl($fileid,$filetitle1); ?>" target="_self"><br/>
<?php echo $filetitle; ?></a><br/>
(Played: <?php echo $timesplayed; ?> times) <a href="<?php echo fileurl($fileid,$filetitle1); ?>" target="_self" ></a></div>
</div>
<?php
if ($fileinrow == '4') {
echo "</br>";
$fileinrow = "0";
}
$fileinrow++;
}
// Display page numbers
if ($pagescount > '1') {
echo "<div >".$prev.$nav.$next."</div>";
}
}
}
?>