Need help simplifying my php table

Posted by user342391 on Stack Overflow See other posts from Stack Overflow or by user342391
Published on 2010-05-17T20:45:53Z Indexed on 2010/05/17 20:50 UTC
Read the original article Hit count: 270

Filed under:
|
|

I am relatively new to php and have a feeling that I am going the long way round when displaying data from mysql.

I have a table a I want to show a few fields from my database.

How would I achieve this without having to echo every bit of the table???

Here is the code:

     <?php
$query1 = mysql_send("SELECT firstname, lastname, email, user, country FROM customers WHERE id='".$_COOKIE['custid']."'");

while ($row = mysql_fetch_array($query1))

{

      echo     ' <table id="account_table" style="width:550px; border:none; ">
              <tr>
                <td width="155">Contact Name</td>';
      echo          '<td width="335">';

    echo $row['firstname'] ;
    echo '&nbsp;';
    echo $row['lastname'];

    echo '</td>
              </tr>
              <tr>
                <td>Email Address</td>
          <td>';
   echo $row['email'];

  echo '  </td>
             </tr>
              <tr>
                <td>Username</td>
                <td>' ;

    echo $row['user'];

    echo '</td>
              </tr>
              <tr>
                <td>Country</td>
                <td>';

    echo $row['country'];

    echo '</td>
              </tr>
              <tr>
                <td>Time Zone</td>
                <td>GMT+1</td>
              </tr>
              <tr>
                <td>Activated</td>
                <td>16 Dec 2009</td>
              </tr>
            </table>';

            }
?>

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql