Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Location
    Eastern, PA
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP and formating for product listings

    Hello - I'm having problems with my code and I have no idea where to go from here - I am connecting the the server fine and my db - I just can't print/display my information in the manor I would most enjoy.

    I have a database with several fields like product title, description and price.
    I have no problem pulling this from my database- but putting into the format i want is the problem.


    Below is an html example of how I want to display each entry:
    <div id="row">
    <table width="640" border="0">
    <tr>
    <td width="100"><img src="../img/ps_icons/yfrm.jpg" width="78" height="170" alt="" style="background-color: #42BD42" /><br />
    <br /></td>
    <td width="527"><div class="CHB1" id="item">Your Financial Road Map</div>
    <div class="BasicTxtM" id="item_desc">
    <p>This is a personalized, confidential report covering every important facet of your financial life. It is based on a straightforward questionare that takes only about 30 minuets to complete. Your personalized report will be mailed to you in about 3 weeks and is filled with information pertaining to your individual financial situation. You may also choose to receive the report in one week by email.<br />
    </p>
    <p><br />
    <span class="style4">$150.00</span><br />
    <br />
    <br />
    </p>
    </div></td>
    </tr>
    </table>
    <br />
    </div>
    </td>
    </tr>
    </table>
    </div>

    Here is my current PHP

    <?php $dbcnx = @mysql_connect('db120a.xxx.com', 'jxxx', 'xxxxxx');
    if (!$dbcnx) {
    exit('<p>Unable to connect to the ' .
    'database server at this time.</p>');
    }

    if (!@mysql_select_db('xxxx_jweb')) {
    exit('<p>Unable to locate the jweb ' .
    'database at this time.</p>');
    }

    $cat = $_GET['cat'];

    $jdpps = @mysql_query("SELECT id, cat, title, subtitle, keywrd, img, descr, price FROM ps WHERE cat='$cat' ORDER BY id");
    if (!$jdpps) {
    exit('<p>Error retrieving from database!<br />'.
    'Error: ' . mysql_error(). '</p>');
    }

    while ($ps = mysql_fetch_array($jdpps)) {
    $id = $ps['id'];
    $cat = $ps['cat'];
    $title = $ps['title'];
    $subtitle = $ps['subtitle'];
    $descr = $ps['descr'];
    $img = $ps['img'];
    $price = $ps['price'];
    echo "<div id="row">";
    echo "<tr>";
    echo "<td width="100" border="0">$img<br />";
    echo "</td>";
    echo "<td width="527"><div class="CHB1" id="item">$title";
    echo "</div>";
    echo "<div class="BasicTxtM" id="item_dec">";
    echo "<p>$descr</p>";
    echo "$price";
    echo "</div>";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "</div>";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "</div>";


    }

    ?>

    Any idea how how to generate this css constrained box for each product would be great!

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    I would eliminate the tables and go with divisions and CSS, preferably an external CSS file. You also do not need all those echo statements, the last nine can go on one line:

    PHP Code:
    echo "</div></td></tr></table></div></td></tr></table></div>"
    Leonard Whistler


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •