JakeSilver Posted June 25, 2008 Share Posted June 25, 2008 Im making a system to display updates, after 5 updates have been displayed i would like a "Previous" button to be show so that the user can go back and view past updates. I have the following code. <?php $forum_count = 5; function index_navigation($index, $count, $num) { if ($index != 0) { print "<a href=\"index.php?forum_look=" . ($index - $count) . "\">More Recent Updates</a> "; } if ($num == $count) { print " <a href=\"index.php?forum_look=" . ($index + $count) . "\">Previous</a>"; } } if (! isset($forum_look) ) { $forum_look = 0; } $query=mysql_query("SELECT * FROM content WHERE page_id = '1' ORDER by `id` DESC LIMIT $forum_look, $forum_count"); echo $forum_look; echo $forum_count; $data=mysql_fetch_object($query); $num=mysql_num_rows($query); while($data=mysql_fetch_object($query)){ echo "<p align='right'><font face='verdana' size='1' >Updated On:- $data->date</font></p>"; echo "$data->text<br><hr>"; The "Previous" button is displayed however once i click it the same Updates show? I think that its not doing something in the query can anyone offer me some help? Many thanks! Jake Link to comment https://forums.phpfreaks.com/topic/111846-help-mysql-query/ Share on other sites More sharing options...
JakeSilver Posted June 25, 2008 Author Share Posted June 25, 2008 bumpity! Link to comment https://forums.phpfreaks.com/topic/111846-help-mysql-query/#findComment-574146 Share on other sites More sharing options...
roopurt18 Posted June 25, 2008 Share Posted June 25, 2008 As far as I can tell you're using $forum_look without it being defined and you're expecting it to be a $_GET parameter. Place this at the top of your script and see if it doesn't contain the information you want to use in your query: echo '<pre style="text-align: left;">' . print_r( $_GET, true ) . '</pre>'; Once you get it working, come back and ask us how to stop SQL injection. Link to comment https://forums.phpfreaks.com/topic/111846-help-mysql-query/#findComment-574261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.