Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: only 5 at the time
04-07-2003, 05:20 PM #1
- Join Date
- Apr 2003
- Canada, Ontario, Mississauga
- Thanked 0 Times in 0 Posts
only 5 at the time
I created a php script, it will get the info from mysql and display it.
My question is, I only want to disply 5 records at the time, user have to click next to view 5 more and so on....
I know how to disply all of them at once, but 5 at the time???
Can someone please help me.
Thank you in advance,
04-07-2003, 07:33 PM #2
This is what I do for my forum:
It passes the start through a variable called start ( $_GET['start']; )PHP Code:
$x = 1;
if($threadAmmount > 5)
echo '<span id="nameDescrip">Pages: </span>';
if(($_GET['start']-5) >= 0)
echo '<a class="arrows" href="page.php?&start='.($_GET['start']-5).'"><</a> ';
for($i = 0; $i < $threadAmmount; $i+=5)
if($_GET['start'] != $i)
echo ' <a class="arrows" href="page.php?&start='.$i.'">'.$x.'</a> ';
echo ' <span id="nameHeading">[ '.$x.' ] </span> ';
if(($_GET['start']+5) < $threadAmmount)
echo ' <a class="arrows" href="page.php?start='.($_GET['start']+5).'">></a>';
That makes sure you only display the files wanted.PHP Code:
$limit = 0;
$query = mysql_query("SOME QUERY");
for($i = 1; $row = mysql_fetch_array($query); $i++)
if($limit >= 5)
if($i == 0 && $i == $_GET['start'] || $i > $_GET['start'])
// Do Whatever with the info
This system also makes a next and back system like on my forum
[ 1 ] 2 3 4 >
Hope this helps.