mikeleblanc Posted November 29, 2008 Share Posted November 29, 2008 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> Link to comment https://forums.phpfreaks.com/topic/134720-variable-not-updating-using-href-passing/ Share on other sites More sharing options...
cooldude832 Posted November 29, 2008 Share Posted November 29, 2008 from the looks of it you aren't showing it all You need to set $rowNumber1 somewhere in the page higher up or that if statement is always gonna win and set it to be 1 Link to comment https://forums.phpfreaks.com/topic/134720-variable-not-updating-using-href-passing/#findComment-701520 Share on other sites More sharing options...
mikeleblanc Posted November 29, 2008 Author Share Posted November 29, 2008 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. Link to comment https://forums.phpfreaks.com/topic/134720-variable-not-updating-using-href-passing/#findComment-701557 Share on other sites More sharing options...
cooldude832 Posted November 29, 2008 Share Posted November 29, 2008 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; ?> Link to comment https://forums.phpfreaks.com/topic/134720-variable-not-updating-using-href-passing/#findComment-701558 Share on other sites More sharing options...
mikeleblanc Posted November 29, 2008 Author Share Posted November 29, 2008 Hey cooldude832, you solved my problem! You're COOL! Please accept my thanks, I really appreciate your help.....I hope you stay around this forum. Link to comment https://forums.phpfreaks.com/topic/134720-variable-not-updating-using-href-passing/#findComment-701563 Share on other sites More sharing options...
cooldude832 Posted November 29, 2008 Share Posted November 29, 2008 I come and go from time to time Link to comment https://forums.phpfreaks.com/topic/134720-variable-not-updating-using-href-passing/#findComment-701722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.