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


pagination problem

Reply
  #1 (permalink)  
Old 11-06-11, 06:21 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
pagination problem

I have this problem with a pagination... you can see at: Tutoring Online - www.chemath.com

this is my code
PHP Code:



<?php

   
function showquestions($sub_id$page$currentpage$newpage)
   {
      
$query "Select count(quest_id) from questions where sub_id = $sub_id";

      
$result mysql_query($query);
      
$row mysql_fetch_array($result);
      if (
$row[0] == 0)
      {
         echo 
"<h2><br>Sorry, there are Questions in this category</h2>\n";

      }
      else
      {

         
$thispage $page;
         
$totrecords $row[0];
         
$recordsperpage 20;
         
$offset = ($thispage 1) * $recordsperpage;
         
$totpages ceil($totrecords $recordsperpage);
         
         

         
$query "SELECT  quest_id, question, LEFT(question, 115) AS first115 from questions  WHERE sub_id=$sub_id ORDER BY question ASC LIMIT $offset,$recordsperpage";
         
$result mysql_query($query);
         while(
$row=mysql_fetch_array($resultMYSQL_ASSOC))
         {
            
$quest_id $row['quest_id'];

            
$question $row['question'];


            echo
"<div id='content2'>";

            
            
$extract $row['first115'];
            
// find position of last space in extract
           
$lastSpace strrpos($extract' ');
           
// use $lastSpace to set length of new extract and add ...
           
echo substr($extract0$lastSpace).'... ';
          echo 
'<a href="details.php?quest_id='.$row['quest_id'].'"> More</a>';

            



            echo
"</div>";

            echo
"<br>";
            echo
"<p>";

         }
         
//echo "</table>\n";

         
if ($thispage 1)
         {
            
$page $thispage 1;
            
$prevpage "<a href=\"$currentpage&cat=$sub_id&page=$page\"><h4>Previous page</h4></a>";
         } else
         {
            
$prevpage "";
         }


         if (
$thispage $totpages)
         {
            
$page $thispage 1;
            
$nextpage " <a href=\"$currentpage&cat=$sub_id&page=$page\"><h4>Next page</h4></a>";
         } else
         {
            
$nextpage "";
         }

         if (
$totpages 1)
            echo 
$prevpage "  " $nextpage;

      }
   }
?>
Can you guys help me to have the next and previous links in every side of the page. THANKS
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
PHP Pagination problem... please help susan PHP 2 05-06-11 05:50 AM
pagination problem esandra PHP 1 09-06-10 05:06 AM
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Pagination Problem lppa2004 PHP 1 03-24-06 07:54 PM
Pagination Problem fraggle PHP 1 02-27-06 08:23 AM


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