Page 1 of 1
Results Per Page Form Select
Posted: Sun Oct 19, 2008 8:58 am
by c0mrade
Hi all,
I have a "problem" with displaying some records. I have a query that returns loads of results about 130 records.. and I want to organize it a bit in form of "Results per page" from select. here is my query :
Code: Select all
$sql="SELECT * FROM members";
$result = mysql_query($sql);
and extracting it
Code: Select all
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$name = $row['name'];
$surname = $row['surnname'];
$points = $row['points'];
$awarded = $row['awarded'];
echo "<tr>
<td><div align=\"center\">$id</div></td>
<td><div align=\"center\">$name</div></td>
<td><div align=\"center\">$surname</div></td>
<td><div align=\"center\">$points</div></td>
<td><div align=\"center\">$awarded</div></td>
</tr>";
}
any hints how to do it .. or split it in more pages or something ? thank you in advance
Re: Results Per Page Form Select
Posted: Sun Oct 19, 2008 9:08 am
by jaoudestudios
There are many ways to do this. Do you want quick and easy or difficult but sexy?!?!
For the quick and easy use LIMIT in your MySql query!
Re: Results Per Page Form Select
Posted: Sun Oct 19, 2008 1:45 pm
by califdon
The word we use to describe what you are asking about is "pagination". Use that word, plus "php", in any search engine and you will find hundreds of references to how to do pagination with php.
Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:00 am
by c0mrade
jaoudestudios: Difficult but sexy is better

if you allocate some time to explain it would be awesome.
califdon: I already did googled "pagination in php" but didn't couldn't do it for some reason ..
Tnx for your replies
Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:05 am
by jaoudestudios
Sure, but you need to make a few decisions first. Do you want it to downgrade gracefully?
Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:08 am
by c0mrade
I'm not sure that I understand "downgrade gracefully" .. sorry I'm not native speaker ..
Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:09 am
by jaoudestudios
I think google will give a better explanation than me.

Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:11 am
by c0mrade
you mean on the "downgrade gracefully" or "results per page" I'm more interested in second ..

Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:26 am
by jaoudestudios
For downgrade gracefully.
I know you are more interested in the 'results page' but if you want to make it sexy you need to make some decisions before you start.
The question is "Do you want it to downgrade gracefull"?
If not then look into ajax for sexy server-side pagination or javascript for still sexy but client-side pagination.
Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 4:36 am
by aceconcepts
I did a quick search and found this
http://php.about.com/od/phpwithmysql/ss ... nation.htm
I typed "php pagination" into Google

Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 7:17 am
by c0mrade
I've found that one also but just now I saw "1 of 4
Prev Next" it all fits now I've done what was needed. Thank you I was just tired last night to understand it. Thank you all again for your posts
Re: Results Per Page Form Select
Posted: Mon Oct 20, 2008 11:53 am
by jaoudestudios
The opposite of downgrade gracefully is progressive enhancement! Look it up. There are some cool features you can do if users have javascript on but will still work if they dont.