Jump to content

Help - MYSQL Query


JakeSilver

Recommended Posts

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 ;D

Link to comment
https://forums.phpfreaks.com/topic/111846-help-mysql-query/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.