Arranging data from My sql DB into a HTML table

Discussion in 'PHP' started by digitalarts, Aug 9, 2009.

  1. #1
    I am retrieving some data from Mysql table using php usng this command:

    $k=mysql_query("select * from user_data where user_login = '$login' limit 1;");
    $r=mysql_fetch_assoc($k);

    I am displaying this data into a HTML table through PHP on my website using this:

    echo "<table border='1'>";
    echo "<tr> <th>Survey</th> <th>Delight</th> <th>Dsat</th> <th>FCR</th> <th>TPR</th> <th>Quality</th> </tr>";

    echo "<tr><td>";
    echo $r['survey_count'];
    echo "</td><td>";
    echo $r['Delight'];
    echo "</td><td>";
    echo $r['Dsat'];
    echo "</td><td>";
    echo $r['FCR'];
    echo "</td><td>";
    echo $r['TPR'];
    echo "</td><td>";
    echo $r['Quality'];
    echo "</td></tr>";

    echo "</table>";

    It displays the data correctly in a table but the problem is the table does not have all equal column width.

    How can I set the width of all the columns equal??

    For ex this is how the current table looks like:

    [​IMG]

    I want all the column in the table to have same width...
     
    digitalarts, Aug 9, 2009 IP
  2. Guttu

    Guttu Peon

    Messages:
    728
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just specify the width of the column

    <td width=100>
    Code (markup):
     
    Guttu, Aug 9, 2009 IP
  3. Kazumael

    Kazumael Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Or set the total table width, as long as you set it wider than it's now :)

    <table border='1' width='500px'>
    HTML:
    Or preferably, use CSS ;-)
     
    Kazumael, Aug 9, 2009 IP
  4. digitalarts

    digitalarts Peon

    Messages:
    105
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks a lot ......I have been able to set it correctly following ur suggestion.
     
    digitalarts, Aug 10, 2009 IP