prev next button problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
buzzby
Forum Newbie
Posts: 9
Joined: Sun Oct 12, 2003 2:13 pm

prev next button problem

Post by buzzby »

this is the script i am using to increment the id and therefore display the next row of information but its not working. take a look for me plase and help me spot why it isnt running properly. the incremental id works but the records are not showing. plus there is something happenin with the id itself. there needs to be a condition that makes it start at id=1 and no lower.

Code: Select all

$result = mysql_query("select * from gstrialforma",$connection); 
$check1= mysql_query("select MIN(id) as '{$_GET['id']}' from gstrialforma"); 
$check1 = mysql_fetch_object($check1); 
$check2 = mysql_query("select MAX(id) as '{$_GET['id']}' from gstrialforma"); 
$check2 = mysql_fetch_object($check2); 
echo "<table border=1 cellpadding=2 cellspacing=2 class=biggertext>"; 
echo "all table headers"; 
if ($myrow = mysql_fetch_array($result)) 
{ 
echo "all row information" 
} 
echo "</table>"; 
echo "<table><tr><td>";//below is my increment script to show the next row of information 
if($check1->id != $_GET['id']) 
{ 
$newid = $_GET['id']-1; 
echo "<a href="tableview4.php?id=$newid" class="biggertext"><- Previous</a>"; 
} 
if($check2->id != $_GET['id']) 
{ 
$newid = $_GET['id']+1; 
echo "<a href="tableview4.php?id=$newid" class="biggertext">Next -></a>"; 
} 
echo "</td></tr></table>"; 
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your asking mysql to alias MIN(id) to 3 or whatever the value of $_GET['id'] is.. same goes for MAX(id), I think you want it as "id".
Post Reply