SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Indiana
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie to PHP Question...

    I am a newbie to PHP and MySQL. I am trying to generate a simple set of tables that outputs general product info. The script below works, but the tables are end to end horizontally. I have tried everything to get them to be separated vertically by a line break but nothing seems to work. Any help is greatly appreciated. Thanks!


    <?php

    $prodlist = mysql_query("SELECT * FROM RelaysSensors");

    while ($test = mysql_fetch_array($prodlist)) {
    $model = $test["ModelNum"];
    $descr = $test["Desc"];
    $ul = $test["ULStand"];
    $listrec = $test["ListRec"];

    // Display the information
    echo( "<table width='600' border='0' align='left' cellpadding='2' cellspacing='1' bgcolor='#000000'>" .
    "<tr><td bgcolor='#EEEEEE'><strong><font class='price'>$model</font></strong></td></tr>
    <tr><td bgcolor='FFFFFF'><strong>Description/strong> $descr<br>
    <strong>UL Listing/strong> $ul $listrec<br>
    <a href='http://www.functionaldevices.com/pdf/$model.pdf'>Data Sheet</a>
    </td></tr></table>
    <p>");
    }

    ?>

  2. #2
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a HTML issue, no PHP problem.

  3. #3
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly, yes this is an HTML issue, try the HTML forum for HTML specific questions.

    Despite that, I'll offer some suggestions to your PHP code, and a solution to your HTML one:

    PHP Code:
    <table width='600' border='0' align='left' cellpadding='2' cellspacing='1' bgcolor='#000000'>
    <?php
    $prodlist 
    mysql_query("SELECT * FROM RelaysSensors");

    while (
    $test mysql_fetch_array($prodlist)) {
       
    $model $test['ModelNum'];
       
    $descr $test['Desc'];
       
    $ul $test['ULStand'];
       
    $listrec $test['ListRec'];
        
        
    // Display the information
       
    echo <<<HTML

       <tr>
          <td bgcolor='#EEEEEE'>
             <strong>
                <font class='price'>
    $model</font>
             </strong>
          </td>
       </tr>
       <tr>
          <td bgcolor='FFFFFF'>
              <strong>Description:</strong> 
    $descr<br />
              <strong>UL Listing:</strong> 
    $ul $listrec<br />
             <a href='http://www.functionaldevices.com/pdf/
    $model.pdf'>           
             Data Sheet</a>
           </td> 
       </tr>
    HTML;

    }

    ?>
    </table>
    As you can see, I've split your multiple tables into one table, with multiple rows.

    Cheers!
    My name is Steve, and I'm a super-villian.

  4. #4
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Indiana
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually this is not what I wanted the code to do at all, but thanks for trying. I appreciate your time.

  5. #5
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nonetheless, this is the code you should use to accomplish what you described above.... simply insert a blank <td></td> with a line break and no background color, and you're set!

    Otherwise, you could have gone to a width="100%" for each table, forcing them to remain vertically...

    Cheers!
    My name is Steve, and I'm a super-villian.


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
  •