Announcement

Collapse
No announcement yet.

multi page database listing

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

  • multi page database listing

    lets say I have a mysql database with a table containing 100+ rows. If I only want to display 20 enteries at a time on a page, how would i do so?

    thanks

    Dimava
    NXSupport Admin

  • #2
    mysql_query("select * from table limit 0,20");

    Comment


    • #4
      PHP Code:
      class pages {
          var 
      $content;

          function 
      pages($table,$limit,$page) {
              
      $mysql = new mysql();
              
      $result $mysql->query("SELECT * FROM `$table`");
              
      $numrows mysql_num_rows($mysql->query);
              
      $mysql->close();

              if (
      ereg("\\?",$page)) {
                  
      $page .= "&";
              } else {
                  
      $page .= "?";
              }
              if (!
      $_GET[offset]) {
                  
      $offset 0;
              } else {
                  
      $offset $_GET[offset];
              }

              if (
      $offset) {
                  
      $prevoffset $offset $limit;
                  
      $content .= "&nbsp;[<A href=\"$page"offset=$prevoffset\">Prev</A>]&nbsp;";
              }
              
      $pages intval($numrows $limit);
              if (
      $numrows $limit) {
                  
      $pages++;
              }
              for (
      $x 1$x <= $pages$x++) {
                  
      $newoffset $limit * ($x 1);
                  if(
      $newoffset == $offset) {
                      
      $content .= "&nbsp;[$x]&nbsp;";
                  } else {
                      
      $content .= "&nbsp;[<A href=\"$page"offset=$newoffset\">$x</A>]&nbsp;";
                  }
              }
              if((
      $pages == 1) || (($offset $limit) == $pages) || (($offset $limit) == ($pages 1))) {
              } else if (!((
      $offset $limit) == $pages) && $pages != 1) {
                  
      $newoffset $offset $limit;
                  
      $content .= "&nbsp;[<A href=\"$page"offset=$newoffset\">Next</A>]&nbsp;";
              }

              
      $this->content "<DIV align=\"center\">$content</DIV>\n";
          }

      Comment


      • #5
        thanks guys
        NXSupport Admin

        Comment

        Related Topics

        Collapse

        Working...
        X