Forum Moderators: coopster
I have a script that scrolls through a number of widgets one by one in order from first to last...
I would like to add the option to scroll through only the 'newest widgets' , so I'd accomplish that by showing them in reverse order
my code for viewing in sequence is this:
$sql="select max(id) as maxid from user ";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
$maxid=$row['maxid'];
$sql="select min(id) as minid from user ";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
$minid=$row['minid'];
//echo $maxid;
if((!isset($widget_id)) or ($widget_id==$maxid))
$sql="select * from user order by id asc limit 0,1";
else $sql="select * from user where id >$widget_id order by id asc limit 0,1";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
if(!isset($id))
$id=$row['id'];
and a link on the page
<a href="view.php?widget_id=<? echo $id;?>">
will show the next widget
I have tried many variations using:
$sql="select * from user ORDER BY date_added DESC";
I am able to display the newest widget but cannot scroll back through them in descending order
What simple code change can I make to do that?
Thanks Very Much
limit 0,1 will give you the first result, to get the second you would need 1,1 and the third 2,1 and so on... Then you should be able to get the correct result from either order (ASC or DESC) statement.
I would use the page num EG $start=$page-1; should get you the right answer to start.
Justin