Jump to content

Variable not updating using href=? passing


mikeleblanc

Recommended Posts

hello why is rowNumber not updating? I'm doing some php paging.  thanks.

 

 

<?php

    if (empty($rowNumber1))

    {

        $rowNumber1 =1;

    }

    $thispage = $PHP_SELF ;

    $rowNumber = $rowNumber1;

    $previous = $rowNumber - 1;

    $next    = $rowNumber + 1;

    echo "SELECT * FROM survey LIMIT ".$rowNumber.", 1";

    $result= executeSQL("SELECT * FROM survey LIMIT ".$rowNumber.", 1");

 

    $row = mysql_fetch_row($result);

  ?>

  ....................

<tr>

  <td><a href="?<?php echo "$rowNumber=$previous";?>">Previous suggestion</a> </td>     

  <td><a href="<?php print("$thispage?rowNumber1=".$next);?>">Next</a></td>

 

  </tr>

 

 

yes, thing is even my next hyperlink

 

http://127.0.0.1/ps4result.php?rowNumber=2

 

doesn't update rowNumber

 

I rewritten it, coz i sent the wrong code

 

<?php

  if (empty($rowNumber))

  {

    $rowNumber = 1;

  }

 

  $thispage = $PHP_SELF ;

  //echo $rowNumber;

  $previous = $rowNumber - 1;

  //echo $previous;

  $next    = $rowNumber + 1;

  //echo $next; 

  echo "SELECT * FROM survey LIMIT ".$rowNumber.", 1";

  $result= executeSQL("SELECT * FROM survey LIMIT ".$rowNumber.", 1");

  //echo $rowNumber;

 

    $row = mysql_fetch_row($result);

    //$rowNumber = $row[rowNum];   

  ?>

 

<td><a href="<?php print("$thispage?rowNumber=".$next);?>">Next</a></td>

 

so after clicking next, http://127.0.0.1/ps4result.php?rowNumber=2 executes and I was hoping now rowNumber = 2 so "SELECT * FROM survey LIMIT ".$rowNumber.", 1" becomes "SELECT * FROM survey LIMIT 2, 1".

 

Thanks.

 

I think I know what your problem is

 

You are looking for $_GET['rowNumber']; but you never do it

 

You might be use to old servers using registered globals on which is a bad thing

try

 

<?php
if(empty($_GET['rowNumber'])){
$rowNumber = 1;
}
else{
$rowNumber = $_GET['rowNumber'];
}
$next = $rowNumber+1;
$last = $rowNumber-1;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.