searls03 Posted January 15, 2012 Share Posted January 15, 2012 so my database has a page number next to each field. What I need to know how to do is make it so that the paging number, ie being able to select the page, if greater than one, will display 1-whatever the highest page number is. does this make sense? any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/255089-paging/ Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 SELECT MIN(column) AS first, MAX(column) AS last FROM table Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308011 Share on other sites More sharing options...
searls03 Posted January 16, 2012 Author Share Posted January 16, 2012 is that a query code? how do I implement it. here is some code: <?php $sql = mysql_query("SELECT MIN(page123) AS first, MAX(page123) AS last FROM products"); while($row = mysql_fetch_array($sql)){ $page = $row['page123']; echo $page; } ?> Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308239 Share on other sites More sharing options...
searls03 Posted January 16, 2012 Author Share Posted January 16, 2012 sorry, I just found out how to do it, and you answered exactly what I asked, but not wanted. I didn't want it to display 1-3 for example, but rather 1 2 3. sorry, again that was my fault. how would I do this? Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308248 Share on other sites More sharing options...
searls03 Posted January 16, 2012 Author Share Posted January 16, 2012 Ok, I am using range, but how do I make it display as a link? currently, nothing shows.... <?php $sql = ("SELECT MIN(page123) AS first, MAX(page123) AS last FROM products"); $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $page1=$row['first']; $page2=$row['last']; } foreach (range($page1, $page2) as $number) { ?> <a href=."<?php $number; ?>".></a> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308254 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 Something like: $result = mysql_query("SELECT COUNT(page123) FROM products"); list($count) = mysql_fetch_row($result); for($i = 1; $i <= $count; $i++) { echo $i . ' '; } Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308255 Share on other sites More sharing options...
searls03 Posted January 16, 2012 Author Share Posted January 16, 2012 but how would I do this with the range function that I wrote? Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308256 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 You almost had it. <a href="<?php echo $number; ?>"><?php echo $number; ?></a> Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308257 Share on other sites More sharing options...
searls03 Posted January 16, 2012 Author Share Posted January 16, 2012 how would I also make the next/previous buttons, and also make it so that only 10 numbers will be displayed at a time, but no ".....#" so like when it is on page 5, that is when the numbers will start moving so on page 5 it is 234567891011, 6 is 3456789101112. etc Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308261 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 Maybe you should have a look at http://www.phpfreaks.com/tutorial/basic-pagination Link to comment https://forums.phpfreaks.com/topic/255089-paging/#findComment-1308265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.