Results 1 to 3 of 3

Thread: help with paging

  1. #1
    Join Date
    Jul 2007
    Location
    cyberjaya
    Posts
    1
    Rep Power
    0

    help with paging

    Can someone please help me.. I'm doing paging for my website. But, my problem is.. the No. column i didnt take it from database, i'm using loop. So when i click on next, the number restarting at 1 2 3 instead of continuing 6,7,8. Hope someone can help me. Thank you.

    PHP Code:
    <?php 

    //connection 
    include 'library/config.php'
    include 
    'library/opendb.php'

    // how many rows to show per page 
    $rowsPerPage 5

    // by default we show first page 
    $pageNum 1

    // if $_GET['page'] defined, use it as page number 
    if(isset($_GET['page'])) 

        
    $pageNum $_GET['page']; 


    // counting the offset 
    $offset = ($pageNum 1) * $rowsPerPage

    $query  "SELECT memo_code, memo_date, memo_title, memo_sender 
               FROM memo where id='
    $memo_code' "
                
    $pagingQuery "LIMIT $offset$rowsPerPage"
    $result mysql_query($query $pagingQuery) or die('Error, query failed'); 



     
    //numbering 
     
    $counter=($pageNum 1) * $rowsPerPage
      
     
    $number"LIMIT $counter$rowsPerPage"
        
    $number=1



    // print the memo info in table 
    echo '<table border="1" width="100%"><tr bordercolor="0" bgcolor="#CCCCCC"><td width="1%" bordercolor="#FFFFFF"><div align="center">NO.</td><td width="3%" bordercolor="#FFFFFF"><div align="center">DATE</td><td width="22%" bordercolor="#FFFFFF"><div align="center">TITLE</td></tr>'
    while(list(
    $memo_code$memo_date$memo_title) = mysql_fetch_array($result)) 

        echo 
    "<tr>"
        
    ?> 

        <td bordercolor='#FFFFFF' bgcolor='#FFFFCC'><div align="center"><? echo $number ?></td> 

        <td bordercolor='#FFFFFF' bgcolor='#CCCCCC'><div align="center"><? echo $memo_date ?></td> 

        <td bordercolor='#FFFFFF' bgcolor='#FFFFCC'><a href="memo_content.php?id=<?php echo $memo_code?>"><?echo $memo_title;?></td> 
        <? 


           $number 
    ++; 




        echo 
    "</tr>"

        echo 
    '</table>'
        echo 
    '<br>'

    // how many rows we have in database 
    $result  mysql_query($query) or die('Error, query failed'); 
    $numrows mysql_num_rows($result); 

    // how many pages we have when using paging? 
    $maxPage ceil($numrows/$rowsPerPage); 

    $self $_SERVER['PHP_SELF']; 

    // creating 'previous' and 'next' link 
    // plus 'first page' and 'last page' link 




    // print 'previous' link only if we're not 
    // on page one 
    if ($pageNum 1

        
    $page $pageNum 1
        
    $prev " <a href=\"$self?page=$page\">[Prev]</a> "

        
    $first " <a href=\"$self?page=1\">[First Page]</a> "

    else 

        
    $prev  '  ';  // we're on page one, don't enable 'previous' link 
        
    $first '  '// nor 'first page' link 


    // print 'next' link only if we're not 
    // on the last page 
    if ($pageNum $maxPage

        
    $page $pageNum 1

        
    $next " <a href=\"$self?page=$page\">[Next]</a> "

        
    $last " <a href=\"$self?page=$maxPage\">[Last Page]</a> "

    else 

        
    $next '  ';  // we're on the last page, don't enable 'next' link 
        
    $last '  '// nor 'last page' link 


    // print the page navigation link 
    echo $first $prev " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " $next $last

    include 
    'library/closedb.php'
    ?>

  2. #2
    Join Date
    Jul 2001
    Location
    Jail
    Posts
    228
    Rep Power
    222
    hmm... aku rasa pagenum punya link dan no. list tu hang kena buat benda yg berlainan... dan pagenum=1 letakkan dalam loop utk reset setiap kali tukar page...

  3. #3
    Join Date
    Aug 2007
    Location
    batu caves
    Posts
    5
    Rep Power
    0
    aku rasa pun cam tu./

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Tutorial - ASP.NET - Paging
    By genzy in forum Website Programming
    Replies: 2
    Last Post: 20-10-2013, 11:44 AM
  2. paging file
    By khairudin in forum Mamak Stall
    Replies: 9
    Last Post: 07-07-2003, 10:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30