Current location: Hot Scripts Forums » Programming Languages » PHP » pagination pumpernickles


pagination pumpernickles

Reply
  #1 (permalink)  
Old 05-17-06, 11:24 AM
pilch pilch is offline
Newbie Coder
 
Join Date: May 2006
Location: Torquay, UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy pagination pumpernickles

Help ! - I've got the actual pagination going thru all my table yet the results displayed are correct. It's like there's two different thigns going on here. Oh and also, the pagination links when clicked just display the tabe fieldnames, no data

PHP Code:

 <?
  
/* DEBUG Section */
 
if ($_POST['debug'] == "on") {
   echo 
"<pre>";
   
print_r($_POST);
   echo 
"</pre>";
 }

 
/* Has a limit been set? If not use default */
 
if ($limit == "" || $limit == "0") {
   
$limit '500';
 }
  
 
$link mysql_connect($dbserver$dbuser$dbpass) or die("Could not connect: " mysql_error());
 
mysql_select_db($dbname$link) or die(mysql_error());
 
$result mysql_query("SELECT * FROM $dbtable");

/* create nice url instead of http://myserver.com/?start=0 | Also
 Assign an initial value to $start if it doesn't have one */
 
$start=$_GET["start"];
 if(!isset(
$start)) $start 0;

 
/* Shows blah records from $dbtable starting @ whatever postition $start is equal to. */
 
if ($operator != "LIKE") {
 
$query "SELECT * FROM $dbtable WHERE $field $operator '$search' LIMIT $start$limit";
 
$result mysql_query($query) or die("Could not connect: " mysql_error());
 }
 else {
 
$query "SELECT * FROM $dbtable WHERE $field $operator '%$search%' LIMIT $start$limit";
 
$result mysql_query($query) or die("Could not connect: " mysql_error());
 }

 
$query2 "SELECT count(*) as count FROM $dbtable";
 
$resultCount mysql_query($query2) or die("Could not connect: " mysql_error());
 
$row mysql_fetch_array($resultCount);
 
$numrows $row['count'];
 
 
/* START OF PAGINATION - Wohoo */ 
 
$temp=ceil(($numrows/$limit)+1);
 if(
$numrows > ($start $limit)) {
   echo 
" <a href=\"" $PHP_SELF "?start=" . ($start $limit) . "\"><b>Next >></b></a> | ";
 }
 
$temp3=0;
 for(
$temp2 1$temp2 $temp$temp2++) {
   echo 
"<a href=\"" $PHP_SELF "?start=" . ($temp3) ."\">";
   if(
$temp3==$start) {
     echo 
"<b style=\"color:#000000;\">$temp2</b></a> | ";
   }
   else {
     echo 
"$temp2</a> | ";
   }
   
$temp3=($temp3+$limit);
 }
 if(
$start 0)
   echo 
"<a href=\"" $PHP_SELF "?start=" . ($start $limit) . "\"><b><< Previous</b></a> ";
   echo 
"<br />";
 
/* END OF PAGINATION - Wohoo */
 
 /* OUTPUTS results to screen + store the record of $dbtable into $row */
 
echo "<span class=\"code\">$query2</span> yielded <b>$numrows Results!</b>\n";
 echo 
"<table border=\"1\">\n";
  
/* outputting table names from mysql ? */
  
$i 0;
  while (
$i mysql_num_fields($result)){
    
$fieldname mysql_field_name($result$i);
    echo 
"<th>$fieldname</th>";
    
$i++;
  }
  while (
$data mysql_fetch_assoc($result)) {
   echo 
"<tr>\n";
   foreach (
$data as $value) {
     echo 
"<td>\n";
     echo 
$value;
     echo 
"</td>\n";
   }
   echo 
"</tr>\n";
 }
 
?>
p.s I sorta tried to adapt this pagination code from 1 of the ace codewalkers' tutorial.
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 lppa2004 PHP 1 03-24-06 07:54 PM
Database abstraction layer - OOP style w. pagination support RaulIONESCU PHP 2 02-27-06 02:19 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 07:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.