Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/170250-solved-variables/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.