PDA

View Full Version : while pagination



Hypertext
08-03-2008, 07:26 PM
<?php
$sql = "SELECT * FROM NEWS";
$query = mysql_query($sql);

$total = mysql_num_rows($query);
$maxnews = 3;
if($total <= $maxnews)
{
//what do i put here??????
}
else{
while($result = mysql_fetch_array($query)) {
// echo news articles if total is no greater than 3
}
}
?>


what do I put there?

Hypertext
08-03-2008, 11:41 PM
I assume I would need to echo the top 3 articles, ordering by id ascending but how would I only display the page number once at the bottom, and calculate the pages...

DJ-Vimto
08-03-2008, 11:49 PM
im no genius when it comes to php...but im sure that the parts in orange are simply 'comments' for the writer of the script, and that they play no part in the execution of the script or function

RedCrisps
08-03-2008, 11:52 PM
Yeh, there just comments =)

Hypertext
08-03-2008, 11:52 PM
I put the echoing articles bit, because I can do that, and the other bit to signify where and what I need help with.

Navicat
09-03-2008, 12:24 AM
That is not the way you do pagination. ;)

http://php.about.com/od/phpwithmysql/ss/php_pagination.htm

Hypertext
09-03-2008, 12:32 AM
Can you put this chunky text you directedme to into a small literary cycle. :)

Ivake
09-03-2008, 12:53 AM
Test the divs and found out

Hypertext
09-03-2008, 01:49 AM
Ivake, your theJOSH I know it, and sthu. Try doing this yourself, oh wait you can't.

Hypertext
09-03-2008, 02:27 AM
Did it, close t.

Want to hide these adverts? Register an account for free!