#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    MO, US
    Posts
    119
    Rep Power
    15
    I have a php script that accesses mySQL and lists the results of what's in the database. One query can have 20 results while others can have over 100. I was wondering how I would be able to tell php or mysql (whatever) to display the results on the page in 4 or 5 evenly distributed columns. Does anyone know what the commands would be? I'm sure this isn't very hard. Thanks!!

    -Bryan
  2. #2
  3. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    use an HTML table

    start the table
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    print "<table>";
    [/code]
    then in your loop that retrieves the records, add the markup for the table rows
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    // begin loop
    print <<<EOF
    <tr>
    <td>
    $field1
    </td>

    <td>
    $field2
    </td>
    .
    .
    .
    </tr>
    EOF;
    // end loop

    </table>
    [/code]

    try it out, lemme know if this is what you were looking for


    [This message has been edited by RyanP (edited September 04, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    MO, US
    Posts
    119
    Rep Power
    15
    not exactly - it's more like all i have is field 1 and i want it to fill like this:
    | means a separation of a table column
    0 means a equal section of field 1
    HEADER
    0|0|0|0
    0|0|0|0
    etc. etc.

    See what I need?
  6. #4
  7. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    I see, try something like this:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    print "<table><tr>";

    $i = 1;

    // loop code here
    {
    if($i <= 4)
    {
    print "<td>$field1</td>";
    $i++;
    }
    else
    {
    print "</tr><tr><td>$val</td>";
    $i = 2;
    }
    }

    print "</tr></table>";
    [/code]
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    MO, US
    Posts
    119
    Rep Power
    15
    Please go to http://www.cityzip.com and click on your state on the map. On the next page you see the cities listed in a single column. What I am trying to do is separate those into 4 or 5 columns evenly distributed. I thought I understood what you were saying but have not been able to get it working.
    The city value is $city and state is $state.
    I am using PHP and the database is in mySQL. Thanks!
  10. #6
  11. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    I don't believe that there is anything more I can say to help you without seeing your script. And if you do post it here, please use the CODE tags and only post the relevant portion(s).

Similar Threads

  1. Show array results in X columns
    By Liviu in forum PHP Development
    Replies: 0
    Last Post: January 22nd, 2004, 06:37 AM
  2. Overwriting mysql query with the query results
    By onerandomday in forum PHP Development
    Replies: 1
    Last Post: January 14th, 2004, 04:45 AM
  3. posting query results to a php page
    By collegebloke in forum PHP Development
    Replies: 4
    Last Post: January 7th, 2004, 10:07 AM
  4. trying to create and populate table with query results
    By alexmasters in forum MySQL Help
    Replies: 1
    Last Post: January 5th, 2004, 10:37 AM
  5. modifying mysql query to refine results
    By jules00 in forum PHP Development
    Replies: 10
    Last Post: December 16th, 2003, 12:54 PM

IMN logo majestic logo threadwatch logo seochat tools logo