Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem with pagination
Old 06-24-2006, 06:09 PM Problem with pagination
Average Talker

Posts: 25
Trades: 0
Hello all

I'm having abit of a problem with this pagination script, the first page displays ok but as soon as you click on the second page it loses the query and you end up with a blank page, here is the script.
PHP Code:
<?php
include "db.php";
$category $_POST['category'];
 
function 
per_page($link$offset) {
global 
$numofpages$page;
$numofpages round($numofpages);
$pagesstart round($page-$offset);
$pagesend round($page+$offset);
if (
$page != "1" && round($numofpages) != "0") {
echo 
str_replace("%page"round($page-1), '<a href="'.$link.'"><<</a>&nbsp; ');
}
for(
$i 1$i <= $numofpages$i++) { 
if (
$pagesstart <= $i && $pagesend >= $i) {
if (
$i == $page) {
echo 
"<b>[$i]</b>&nbsp;";
}
else {
echo 
str_replace("%page""$i"'<a href="'.$link.'">'.$i.'</a>&nbsp; ');
}
}
}
if (
round($numofpages) == "0") {
echo 
"[$i]";
}
if (
$page != round($numofpages) && round($numofpages) != "0") {
echo 
str_replace("%page"round($page+1), '<a href="'.$link.'">>></a>');
}
}
/* Set How many results to display per page */
$pp "4";
/* Select the table that you want to view, you can add things like WHERE something='something' */
$table "hw73ksu349x_hjsd63";
$total mysql_result(mysql_query("SELECT COUNT(title) FROM $table WHERE category='$_POST[category]' ORDER BY pr DESC"),0); 
$numofpages $total $pp
if (!isset(
$_GET['page'])) { 
$page 1

else { 
$page $_GET['page']; 

$limitvalue $page $pp - ($pp); 
/* Display the rows */
$query "SELECT * FROM $table WHERE category='$_POST[category]' ORDER BY pr DESC LIMIT $limitvalue$pp";
$result mysql_query($query);
while(
$r=mysql_fetch_array($result))
{
if (
$e == "0"){ $color="#C1F2FF"$e=1; }else{ 
$color="#93EAFF"$e=0; }
echo 
"<table width='100%' border='0' cellspacing='1' cellpadding='0'>
<tr>
<td width='77%'><span class='style20'><a href='"
.$r['link']."'>".$r['title']."</a> </span></td>
<td width='23%'><a href='mailto:"
.$r['email']."'>Email</a></td>
</tr>
</table><hr>"
;
}
/* Display the pages down the bottom */
echo '<center><br>Pages: '.round($numofpages).'<br>';
per_page("?page=%page""4");
?>
I would be very greatful if you could help me and would be willing to make a small donation to somebody via paypal. Pm me here or post a reply. Thank you
__________________
*
Please login or register to view this content. Registration is FREE
*
Please login or register to view this content. Registration is FREE
*
Please login or register to view this content. Registration is FREE

Last edited by techwench; 06-26-2006 at 11:38 AM.. Reason: code highlight php
NightCoder is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-25-2006, 10:45 PM Re: Problem with pagination
ChancesAre's Avatar
Skilled Talker

Posts: 84
Trades: 0
pagination is very easy my friend, before i can help can you enclose that in code/php tag?
ChancesAre is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with pagination
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47817 seconds with 12 queries