ajmcoder
08-09-2008, 07:32 PM
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!
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!