nextpage help needed!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    nextpage help needed!

    I need help in making nextpage with PHP....
    When i retrieve data from MySQL ,
    I know to show limited number of rows but i need to show the other in next page.
    5rows per page.

    Example , when a page is viewed , 5rows are shown and 5 in the next page and so on.

    Please help me...if possible explain it.

    Thanks.

    #2
    Code:
    <?php
    
    //  Of course connect your mysql first :)  //
    
    //get in what page are you
    if(!isset($_GET[&#39;page&#39;])){
    $page = 1;
    } else {
    $page = $_GET[&#39;page&#39;];
    }
    
    $max_results = 5;//you can change how much row&#39;s show in page
    $to = ($page * $max_results) - $max_results;
    $form = $to - $max_result;
      
    $sql = mysql_query("SELECT * FROM `some_table` LIMIT $to, $max_results");
          
    while($row=mysql_fetch_array($sql)){
    //printing your data
    }
    
    $page_sql = mysql_query("SELECT * FROM `some_table`");
    $total_results = mysql_num_rows($page_sql);//how much rows are in table
    $total_pages = ceil($total_results / $max_results);
    
    //go back if it need
    if($page > 1){
    $prev = ($page - 1);
    print &#39;[url="some.php?page=&#39;.$prev.&#39;"]Back[/url]
    &#39;;
    }
    
    //go to next page if that exist
    if($page < $total_pages){
    $next = ($page + 1);
    print &#39;[url="some.php?page=&#39;.$next.&#39;"]Next[/url]
    &#39;;
    }
    
    ?>
    Sorry but my english is not so well to comment it more ... i hope it will help you

    Comment


      #3
      Code:
      <?php
      
      //  Of course connect your mysql first :)  //
      
      //get in what page are you
      if(!isset($_GET[&#39;page&#39;])){
      $page = 1;
      } else {
      $page = $_GET[&#39;page&#39;];
      }
      
      $max_results = 5;//you can change how much row&#39;s show in page
      $to = ($page * $max_results) - $max_results;
      $form = $to - $max_result;
        
      $sql = mysql_query("SELECT * FROM `some_table` LIMIT $to, $max_results");
            
      while($row=mysql_fetch_array($sql)){
      //printing your data
      }
      
      $page_sql = mysql_query("SELECT * FROM `some_table`");
      $total_results = mysql_num_rows($page_sql);//how much rows are in table
      $total_pages = ceil($total_results / $max_results);
      
      //go back if it need
      if($page > 1){
      $prev = ($page - 1);
      print &#39;[url="some.php?page=&#39;.$prev.&#39;"]Back[/url]
      &#39;;
      }
      
      //go to next page if that exist
      if($page < $total_pages){
      $next = ($page + 1);
      print &#39;[url="some.php?page=&#39;.$next.&#39;"]Next[/url]
      &#39;;
      }
      
      ?>
      Sorry but my english is not so well to comment it more ... i hope it will help you [/b]
      Thanks mate!!

      Comment


        #4
        No problems

        Comment


          #5
          how do one create a next page option in a php file when you have links to files stored on another server?

          3gpfiles.php
          Code:
          <?
          echo "<a href=\"http://filestore.com/mobile/files/file1.3gp\">file1.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file2.3gp\">file2.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file3.3gp\">file3.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file4.3gp\">file4.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file5.3gp\">file5.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file6.3gp\">file6.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file7.3gp\">file7.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file8.3gp\">file8.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file9.3gp\">file9.3gp</a>
          ";
          echo "<a href=\"http://filestore.com/mobile/files/file10.3gp\">file10.3gp</a>
          ";
          ?>
          how do put the code in to show 5 links per page? and what should the code look like?

          Code:
          $prev_page = $page -1;
          echo "
          <a href=\"3gpfiles.php."?page=$prev_page\">Prev</a>
          ";
          $next_page = $page + 1;
          echo "
          <a href=\"3gpfiles.php."?page=$next_page\">Next</a>
          ";
          = = = = =
          The more you laugh...the longer you live.
          Read more jokes at
          http://fun-files.co.cc

          Comment


            #6
            $conf["items_per_page"] = 5;

            Comment


              #7
              Hey....i know that mate...

              Comment

              Working...
              X