SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how can i list the database result like this

    i'm using php to get some info from mysql database
    it list the result like this
    x1
    x2
    x3
    x4
    ..

    how can i make it list the result like this

    x1 x2 x3

    x4 x4 x6

    ...

    thanx

  2. #2
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you talking about listing them in an HTML table ? Or is it about listing them that way in a PHP array ?

  3. #3
    SitePoint Zealot theFinn's Avatar
    Join Date
    Oct 2000
    Location
    Edmonton
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm going to assume actuall display.. its pretty easy:

    PHP Code:
    $sql "SELECT number FROM table ORDER BY number";

    if(!
    $result mysql_query($sql))
    {
      die(
    "Could not query database");
    }

    for(
    $i 0$row mysql_fetch_array($result); $i++)
    {
       if(!(
    $i 3))
       {
          echo 
    "<br>";
       }
       echo 
    $row['number'] . " ";

    Its the !($i % 3) that does it. The modulus operator finds the reminder when you devide the 2 numbers. So when $i is diviable by 3 (there is a 0 remainder) it puts a <br>, so every 3rd result you get a line break... easy eh?
    - theFinn
    Creator and Project Manager, phpBB
    http://www.theFinn.net
    http://www.tarotclass.com

  4. #4
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shin Ma, I was talking about listing them in an HTML table.
    Well its not very easy (for me at least)
    Thanx alot

  5. #5
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing how can I list 20 result only in a page and use something like:
    Pages (X): [ < 1 2 3 4 > >>]
    To list the rest, where X is the number pages, like the one used in this fourm.

  6. #6
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there was a tutorial about this on phpbuilder.com, but i can't remember where.
    search around on there, or here at the forums for multiple pages etc...
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

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