Ninjakreborn Posted March 2, 2007 Share Posted March 2, 2007 I have had a system I have been re-using for pagination for a long time. I originally created it, and was rather happy with how well it worked. Basically: <p>Click thumbnail for larger view.</p> <?php if ($_GET['rownumberprev']) { $rownumber = mysql_real_escape_string($_GET['rownumberprev']); }elseif ($_GET['rownumbernext']) { $rownumber = mysql_real_escape_string($_GET['rownumbernext']); }else { $rownumber = 0; } $limit = 20; // get total amount of rows in database $year = date("Y"); $month = date("n"); $selecttemp = "SELECT * FROM specialimagesystem;"; $querytemp = mysql_query($selecttemp); $total_rows = mysql_num_rows($querytemp); // get current year and date, for use with query $select1 = "SELECT * FROM specialimagesystem LIMIT $rownumber, $limit;"; $query1 = mysql_query($select1); while ($row1 = mysql_fetch_array($query1)) { echo "<div class=\"specialimagesystem\">\n"; $target = "/specialimages/"; $width = "100px"; $height = "100px"; echo "<a href=\"{$target}{$row1[name]}\" class=\"thickbox\" title=\"{$row1[description]}\" rel=\"gallery1\"><img src=\"{$target}{$row1[name]}\" width=\"{$width}\" height=\"{$height}\" alt=\"{$row1[name]}\" /></a>"; echo "<span style=\"float:left;\">"; // starts span for price and id echo $row1['description']; echo "<br />"; if ($row1['price'] != "") { // if price is set, then show it echo "Price: $" . $row1['price']; echo "<br />"; }// either way show the id echo "ID: " . $row1['id']; echo "</span>"; echo "<br /></div>\n"; } ?> </div> <div class="pag"> <?php // pagination script part down here if ($rownumber != 0) { $rownumberprev = $rownumber - $limit; echo "<a href=\"totalinventorypictures.php?rownumberprev={$rownumberprev}\">Previous Page</a>"; echo "<br />"; } if ($rownumber <= ($total_rows - $limit)) { $rownumbernext = $rownumber + $limit; echo "<a href=\"totalinventorypictures.php?rownumbernext={$rownumbernext}\">Next Page</a>"; } ?> </div> Ok that same system I have replicated for a very long time. Sometimes it has needed more modification than others. Like some situations where I needed to integrate a more powerful system or instead of showing results it might have been showing htem through a search query, or multiple search queries. Each time is added an extra layer of difficulty, but I was able to modify the same one into something that worked for each situation. Now I am faced with a question from a client. He wants numbered pages 1-2-3-4-5-6-7-8 One number for each page, so they can just click ont he page number, Is there a way I can modify my existing script into a basic script for that kind of funtionality, then I could modify it from there. I am going to have to replicate it into more advanced forms for the other pages with search queries, and everything else. That is the problem, I am having trouble making a base modification into this format. Is it even possible with the current way I am setting up the pagination.? Quote Link to comment https://forums.phpfreaks.com/topic/40911-solved-pagination-system/ Share on other sites More sharing options...
AndyB Posted March 2, 2007 Share Posted March 2, 2007 tutorials -> http://www.phpfreaks.com/tutorials/43/0.php You could have found it in five seconds Quote Link to comment https://forums.phpfreaks.com/topic/40911-solved-pagination-system/#findComment-198134 Share on other sites More sharing options...
Ninjakreborn Posted March 2, 2007 Author Share Posted March 2, 2007 Yes, but the reason I was asking in this manner. Logically speaking I could look at this tutorial and get an idea (I looked over it and already have the idea in my head), which would mean I would have to rewrite all 4-5 occurrences of the system. My pagination system is completely different from that one, so it would require me to rewrite the whole thing, queries and all. In the end I was wondering if there might be a way to simply modify what I had which would add in the extra feature (page numbers), then replicate the modification throughout the rest of the system as needed. Instead of rewriting each system individually. Quote Link to comment https://forums.phpfreaks.com/topic/40911-solved-pagination-system/#findComment-198139 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.