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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.