Web Hosting Talk







View Full Version : next and previous setup problem


lochie
05-06-2005, 11:05 PM
I've got a script that contains 190 items, I want to display 30 per page and use < PREVIOUS 2 | 3 | 4 NEXT >. I've tried this myself (see below) using a script from spoono.com. I should have known better as nothing I try form spoono ever works, and everyone else seems to have the same problems according to their discussion board.

Here is what I have..

<?php

if(!isset($_GET['act']) || $_GET['act'] != 'play'){
echo $sys->makeGamesList();
} else {
if(isset($_GET['id'])){
echo $sys->makeGameHtml($_GET['id'], $_GET['cid']);
} else {
echo '<div style="margin: 30px;">
<strong>Error: </strong>Invalid Input<br /><br />
<a href="'.$_SERVER['PHP_SELF'].'">Click here to return Home</a>
</div>';
}
}


//initialize the start to 0
if(!$rowstart) $rowstart=2;

//mysql queries
$result = mysql_query("select * from games limit $rowstart,30");
$result2 = mysql_query("select * from games");

//find the number of total rows in the shoutbox total
$numrows = mysql_num_rows($result2);

//put all the code here for running the script itself using $result in the while loop

//put where you want the next prev to appear
if ($rowstart > $numrows)
{
echo "<A HREF=\"$php_self?rowstart=$rowstart-30\">< Next Page </A>";
}

if($rowstart+30<$numrows)
{
echo "<A HREF=\"$php_self?rowstart=$rowstart+30\"> Next Page </A>";
}

?>


I'd be grateful if someone could point me in the right direction.

I'm available on MSN: lee@lmwebdevelopment.co.uk
AIM: jester79lm
ICQ: 168963749

So if you need to ask me questions, I'm usually available when not sleeping. :eek:

azizny
05-07-2005, 12:06 AM
This tutorial well help you out:

http://www.phptricks.com/?view=&lesson_id=25&section=2

Peace,

lochie
05-07-2005, 05:08 AM
Nope, it didn't help. I am not that great with php, so I'd probably need someone to supply me with the code already written. =\