Results 1 to 3 of 3

Thread: How do i display mysql data in a 5 column 5 row table ?

                  
   
  1. #1
    Advance Entrepreneur Array
    Join Date
    Aug 2011
    Posts
    201
    Country: Albania
    Post Thanks / Like
    Rep Power
    1

    Default How do i display mysql data in a 5 column 5 row table ?







    Hi,

    i am trying to display data from a mysql database in a HTML table in a certain way, i can get the data to display in a one column list but i require the data to display in a five column five row table, any ideas on how i can go about doing this ?

    P.S. i use PHP to call the mysql data.

    Thanks

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  2. #2
    Junior Entrepreneur Array
    Join Date
    Aug 2011
    Posts
    43
    Country: Vietnam
    Post Thanks / Like
    Rep Power
    0

    Default







    I'm in a good mood tonight, so:
    PHP Code:
    <?php
    $html
    ="<table>";
    $cptLine=0;
    $q="select a, b, c from tbl";
    $r=mysql_query($q);
    while(
    $o=mysql_fetch_object($r)){
    if(
    $cptLine===0){
    $html.="<tr>";
    foreach(
    $o as $key=>$val){
    $html.="<th>{$key}</th>";
    }
    $html.="</tr>";
    }
    $html.="<tr>";
    foreach(
    $o as $key=>$val){
    $html.="<td>{$val}</td>";
    }
    $html.="</tr>";
    $cptLine++;
    }
    $html.="</table>";

    echo
    $html;
    ?>

    Not tested, but you get the idea, at least.
    BDS Real Estate Company
    Go to my website
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    to learn about real estate in Vietnam: Home sales , Apartment for sale, Feng Shui ...

  3. #3
    Junior Entrepreneur Array
    Join Date
    May 2012
    Posts
    31
    Country: India
    Post Thanks / Like
    Rep Power
    0

    Default







    You have several options depending on how fancy you want to get with your HTML/CSS. You can try to keep each to 50% width and float them left and the elements should automatically arrange themselves in two columns. You could probably do it with a Modulus operator which will get the remainder of a devision.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    |
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Table Percentage Width in IE
    By plaqichczj in forum Web Design & Blog Discussion
    Replies: 0
    Last Post: 11-11-2011, 09:43 PM
  2. Table Question
    By shnconger in forum Web Design & Blog Discussion
    Replies: 0
    Last Post: 11-09-2011, 11:15 PM
  3. table scroll prob.
    By shnconger in forum Web Design & Blog Discussion
    Replies: 0
    Last Post: 11-01-2011, 10:45 PM
  4. Replies: 0
    Last Post: 09-13-2011, 10:12 PM
  5. Multiple Column Setup Issue
    By ashiq_201095 in forum Programming
    Replies: 0
    Last Post: 02-09-2010, 03:44 AM

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
  •  
website stat