Current location: Hot Scripts Forums » Programming Languages » PHP » Pagination


Pagination

Reply
  #1 (permalink)  
Old 03-19-06, 01:41 PM
newphoria newphoria is offline
New Member
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Pagination

Thanks for reading in advance. I'm a newbie here and I have some issues about my pagination script.Most of the tutorials I found on the web are basically queries that are predefined.I'm currently using this script which is from Michael P. Bourque (michael@mbourque.com).so this is the script.
PHP Code:

<?php


$Host      
"";
$User      "";
$Password  "";
$DBName    ""// Database name
$TableName ""// Name of table to display
$Pagesize  "10";
$rateID    "$_POST[select]";
// Do not edit below this line

//echo $rateID; just to test whether it holds a value
$Link mysql_pconnect ($Host$User$Password);

if ( 
$Pagesize ) {
    if( !
$start $start 0;
    
pagination($start,$Link,$DBName,$TableName,$Pagesize,$rateID);
    
$PaginationQuery "LIMIT " $start ", " $Pagesize;
}

$Query "SELECT * FROM $TableName WHERE survey = $rateID"$PaginationQuery;
$Result mysql_db_query ($DBName$Query$Link);

// Create a table with headers.
print ("<TABLE BORDER=0>\n");
print (
"<TR>\n");
for (
$i 0$i mysql_num_fields($Result); $i++) {
    print 
"<TD>".mysql_field_name($Result$i)."</TD>\n";
}
print (
"</TR>\n");

// Fetch the results from the database.

while ($Row mysql_fetch_array ($Result)) {
     print (
"<TR>\n");
    for (
$i 0$i mysql_num_fields($Result); $i++) {
        print 
"<TD>$Row[$i]</TD>\n";
    }
    print (
"</TR>\n");
}
print (
"</TABLE>\n");

mysql_close ($Link);

function 
pagination($start,$Link$DBName$TableName$Pagesize$rateID) {

    
//$j = '$_POST[select]';
    
if ( !$Pagesize ) return;

    
$Query "SELECT count(*) as count FROM $TableName WHERE survey = $rateID";
    
$Result mysql_query($Query);
    
$row mysql_fetch_array($Result);
    
$numrows $row['count'];
    if(
$start >= $Pagesize) {
       echo 
"<a href=\"" $PHP_SELF "?Pagesize=$Pagesize&start=" . ($start $Pagesize) .
            
"\">Previous</a> | \n";
    } else {
            echo 
"Previous | \n";
    }
    if(
$numrows > ($start $Pagesize)) {
       echo 
"<a href=\"" $PHP_SELF "?Pagesize=$Pagesize&start=" . ($start $Pagesize) .
            
"\">Next</a>\n";
    } else {
            echo 
"Next | \n";
    }
    print 
"Page " floor(($start $Pagesize)+1);
    print 
" of " ceil(($numrows $Pagesize));
    print 
" | " $numrows " Records";

}

?>
the problem is I kept getting error or blank result whenever I click next page and worst when I navigate to previous the page went blank. Really appreciate the help. Thanks in advance.

Last edited by Christian; 03-19-06 at 02:51 PM. Reason: Please use [PHP]php[/PHP] when posting php code
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination Problem fraggle PHP 1 02-27-06 08:23 AM
Modification needed for my pagination please help. 0o0o0 PHP 5 10-16-05 11:09 PM
Pagination karlcore Hot Scripts Forum Questions, Suggestions and Feedback 0 09-17-05 08:03 AM
Small Job, Easy Money. Pagination Script... themodestguy Job Offers & Assistance 3 08-28-05 07:26 PM
Pagination MrDarko PHP 1 09-28-04 08:10 AM


All times are GMT -5. The time now is 06:38 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.