lostprophetpunk Posted August 14, 2009 Share Posted August 14, 2009 Hello all, I am currently having some trouble with some variables on my page. The problem is that it is supposed to read the 'n' off of the /blog/?n=1 (1 used for example), but it doesn't seem to do this. The code is being used for a pages system. The code I have so far is... $pn = mysql_real_escape_string( $_GET['n'] ); $sql40 = "SELECT * FROM `posts` ORDER BY `id`"; $res40 = mysql_query($sql40) or die(mysql_error()); $rows = mysql_num_rows($res40); $limit = 0; if($pn = 1){ $limit = 4; }else if($pn= 2){ $limit = 8; } $perpage = 4; $sql4 = "SELECT * FROM `posts` ORDER BY `id` desc LIMIT ".$limit.",".$perpage.""; $res4 = mysql_query($sql4) or die(mysql_error()); I thought that would work, changing the query based on the two variables: $limit and $perpage, but it doesn't work. I am trying to make it so that if it was on page 1...it would display the latest 4 rows from the database, then on page 2 it would display the next 4, and so on until it reaches the end. If anyone could help out, that would be awesome. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/170250-solved-variables/ Share on other sites More sharing options...
wildteen88 Posted August 14, 2009 Share Posted August 14, 2009 Have a read of this Pagination tutorial. It will help you with what you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/170250-solved-variables/#findComment-898073 Share on other sites More sharing options...
lostprophetpunk Posted August 14, 2009 Author Share Posted August 14, 2009 That has helped me alot, thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/170250-solved-variables/#findComment-898249 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.