SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast raynebair's Avatar
    Join Date
    Dec 2000
    Location
    Alabama
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am retreiving data from a database and I want it to output into a table with 2 columns...

    so that it will put the first record in row1, col1; next record in row1, col2; then move to the next row and keep doing that till all records are in the 'table'.

    I am sick and my brain cannot function long enough to figure this out.
    Can anyone help...I need it for php/mysql.

    Thanks in advance.


  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know if this is the best way to do it, but you could do something like..

    //mysql connect, selects etc

    $col = 0;

    echo ("<table>");

    if($myrow = mysql_fetch_array($result))
    do {

    switch ($col) {
    case 1:
    echo ("<tr><td>".$tdvar."</td>");
    $col = 2;
    break;

    case 2:
    echo ("<td>".$tdvar."</td></tr>");
    $col = 1;
    break;

    }
    } while($myrow = mysql_fetch_array($result));

    echo ("</table>");



  3. #3
    SitePoint Enthusiast raynebair's Avatar
    Join Date
    Dec 2000
    Location
    Alabama
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Peter! That worked perfectly.


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
  •