Results 1 to 2 of 2

Thread: DB question

  1. #1
    Join Date
    Feb 2007
    Posts
    2

    Arrow Unanswered: DB question, please help!

    Hi!

    I have a table.. Structure is:
    PHP Code:
    -- 
    -- 
    Table structure for table `database`
    -- 

    CREATE TABLE `database` (
      `
    IDvarchar(255) default NULL,
      `
    Quotevarchar(255) default NULL,
      `
    Namevarchar(255) default NULL,
      
    KEY `Name` (`Name`)
    ENGINE=MyISAM DEFAULT CHARSET=latin1
    And for example few entries..
    PHP Code:
    INSERT INTO `databaseVALUES ('12714''"Do what thou wilt" shall be the whole of the law.''Aleister Crowley'); 
    I'm using this code, to call my database values into my site.
    PHP Code:
    $result mysql_query("SELECT * FROM database ORDER BY ID"
    or die(
    mysql_error());  

    echo 
    "<table border='0'>";
    echo 
    "<tr> <th>ID</th> <th>Quote</th> <th>Author</th> </tr>";

    while(
    $row mysql_fetch_array$result )) {

        echo 
    "<tr><td>"
        echo 
    $row['ID'];
        echo 
    "</td><td>"
        echo 
    "<cite>".$row['Quote']."</cite>";
        echo 
    "</td><td>"
        echo 
    $row['Name'];
        echo 
    "</td></tr>"

    It throws me all entries in one page.. Can i have for example 10 entries in one page, and 10 in the other & so on...

    thanks in advance
    Last edited by matik; 02-27-07 at 14:58.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    as you are using PHPyou could use a prewritten class..... have a look at phpclasses I think there is a paging class there

    if that isnt suitable then you need to roll your own function that calls the page recursively with a page or record number and the same search parameters

    you then extract the records you want using the limit function
    say if you displayed 20 records per page, and you want to display page 5 then you need the first 100 records, you bin records 1..80, and display 81..100

    HTH
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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