darkfreaks Posted December 23, 2007 Share Posted December 23, 2007 ok so how would i take the following function and add it to the following file? Page Function: <?php if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM table LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["users"]); echo("</td>n<td>"); echo($row["usersID"]); echo("</td>n</tr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result); ?> Category.php: <?php $Category = $_GET['Category']; $SEO_Title = "$Category wallpapers"; $SEO_Description = "Download the best $Category wallpapers FREE. We provide 800x600 and 1280x1024 sized images."; $SEO_Keywords = "wallpaper, wallpapers, naruto, free, ".$Category; $SEO_H1 = "Free $Category wallpapers."; $image_path ="../.."; include_once("skin.php"); echo $header; echo "<h2>$Category wallpapers</h2>"; if ($image_path == "") { $image_path=$_SERVER['REQUEST_URI']; } if (substr($image_path,strlen($image_path)-1,1) != "/") $image_path=$image_path."/"; //Category wallpapers. #get the category ID $cCategory = str_replace("+", " ", $Category); $cQuery = "SELECT * FROM `Categories` WHERE `name`='$cCategory' LIMIT 1"; $cResult = mysql_query($cQuery) or die(mysql_error()); if (mysql_num_rows($cResult) <= 0) { echo "There are currently no wallpapers in this category."; } else { $Row = mysql_fetch_object($cResult); $id = $Row->id; $result = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') AND `approved` = '0' ORDER BY `ID` DESC"); $x = 0; if (mysql_num_rows($result) <= 0) { echo "There are currently no wallpapers in this category."; } else { while ($row = mysql_fetch_assoc($result)) { $x += 1; echo "\n".'<div class="Box Left">'."\n\t"; echo '<div style="font-size: 1em; margin-bottom: 5px;"> <a href="'.$image_path.'wallpaper/'.str_replace (" ", "-", $row['Title']).'/">'.$row['Title']."</a></div>"; echo '<a href="'.$image_path.'wallpaper/'.str_replace(" ", "-", $row['Title']).'/"> <img class="Thumbnail" src="'.$image_path.'images/wallpapers/'.$row['Thumbnail'].'" alt="'.$row['Name'].'" /> </a>'; echo '<div class="Clear"></div>'."\n"; echo '</div>'; if (!is_int($x/3)){ echo '<div class="Spacer"> </div>'; } } } } echo '<div class="Clear"></div>'; echo $footer; ?> Quote Link to comment https://forums.phpfreaks.com/topic/82876-solved-modifying-page-function-into-a-page/ Share on other sites More sharing options...
darkfreaks Posted December 23, 2007 Author Share Posted December 23, 2007 if anyone has a simpler way of doing previous and next pages with limits please feel free ot share Quote Link to comment https://forums.phpfreaks.com/topic/82876-solved-modifying-page-function-into-a-page/#findComment-421527 Share on other sites More sharing options...
trq Posted December 23, 2007 Share Posted December 23, 2007 There is no function in your initial post, making your question extremely vague. Quote Link to comment https://forums.phpfreaks.com/topic/82876-solved-modifying-page-function-into-a-page/#findComment-421545 Share on other sites More sharing options...
darkfreaks Posted December 23, 2007 Author Share Posted December 23, 2007 nevermin figured it out Quote Link to comment https://forums.phpfreaks.com/topic/82876-solved-modifying-page-function-into-a-page/#findComment-421551 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.