chrisb
04-11-2007, 03:53 AM
Wondering if someone could help me with a Previous || Next script I’m working on:
Now what I want to do is:
Load a story from the database that;s a news story and the user can click on the previous and next buttons to go to the next news story in the database
Now I’ve set-up this script which works, but it has floors:
<?php
$story_id = $_GET['story_id'];
$link = '/index.php?story_id=';
$SQL = "Select * FROM cms_stories where section='news' LIMIT 1";
$result = mysql_query($SQL) OR die(mysql_error());
while ($row = mysql_fetch_assoc($result)){
echo '[<a href="',$link,$story_id-1,'">Prev</a>] || [<a href="',$link,$story_id+1,'">Next</a>]';
}
?>
It ignores the query and just outputs the next and previous numbers - ie if I was on story 118:
previous comes out as: 117
next comes out as:119
Nomatter if the section=news or not?
Any advice please?
Thanks
Now what I want to do is:
Load a story from the database that;s a news story and the user can click on the previous and next buttons to go to the next news story in the database
Now I’ve set-up this script which works, but it has floors:
<?php
$story_id = $_GET['story_id'];
$link = '/index.php?story_id=';
$SQL = "Select * FROM cms_stories where section='news' LIMIT 1";
$result = mysql_query($SQL) OR die(mysql_error());
while ($row = mysql_fetch_assoc($result)){
echo '[<a href="',$link,$story_id-1,'">Prev</a>] || [<a href="',$link,$story_id+1,'">Next</a>]';
}
?>
It ignores the query and just outputs the next and previous numbers - ie if I was on story 118:
previous comes out as: 117
next comes out as:119
Nomatter if the section=news or not?
Any advice please?
Thanks