next & previous prob

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

Wed Mar 05, 2003 12:27 pm

I had set up the script just to SELECT * which was working perfectly showing all records including image file path to Image Folder.

The problems started when I introduced the page LIMIT, next & Previous function below.

Could someone have a look at it I have made notes the parts that are giving problems. Also is there a way to stop the Previous part of the function returning back to the search page I suppose I could do an IF statement to stop it appearing if there are none or only one record returned.

if(!isset($start)) $start = 0;

$query = "SELECT * FROM table LIMIT " . $start . ", 10";
//do database connection

$result = mysql_query($query); //you should do error checking
//display data

// need another query to get the total amount of rows in our table

$query = "SELECT count(*) as count FROM table";
$result = mysql_query($query);
$row = mysql_fetch_array($result);//Undefined variable: result and mysql_fetch_array(): supplied argument is not a valid MySQL result resource errors

$numrows = $row['count'];

if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 10) .
"\">Previous</a><BR>\n"; //getting parse error here

if($numrows > ($start + 10))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 10) .


Oleg Butuzov
Last Samuray
Last Samuray
Posts: 824
Joined: Sun Jun 02, 2002 3:09 am

Thu Mar 06, 2003 2:48 am

table - is reserved word...

Post Reply