473,386 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PHP code destroying the alignment of my table???

40
EDIT: Nevermind, I fixed this by using a <BR /> instead of trying to write option_a to a new row of the table. Thanks all!

Hi all,

This has been haunting me for over a day now, and I can't understand what's wrong with it. My shopping cart table's format is misaligned, and I have no clue why. Please help!

My PHP code is pulling the cart contents from my SQL database, and then generating html to create the format. The html looks fine, and the good people on the html forum can't find the problem either. I think the PHP must be the issue.

Here's a snapshot of the misaligned portion of the screen:



Here's the html code when the page source is viewed:

[HTML]<table width="800" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="Images/main_box_view_cart.jpg" alt="Clothing" width="800" height="70" /></td>
</tr>
<tr>
<td><img src="Images/spacer_20.jpg" alt="Clothing" width="800" height="20" /></td>
</tr>
</table>

<table width="800" align="center" border="0" cellpadding="0" cellspacing="0">

<tr>
<td width="50" bgcolor="#FFFFFF"></td>
<td width="700" class="cart_header">Your Shopping Cart</td>
<td width="50" bgcolor="#FFFFFF"></td>
</tr>
</table>
<table width="800" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50" bgcolor="#FFFFFF"></td>

<td width="700" class="cart2">&nbsp;</td>
<td width="50" bgcolor="#FFFFFF"></td>
</tr>
</table>
<table width="800" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50" bgcolor="#FFFFFF"></td>
<td width="300" class="cart_header">Product</td>
<td width="100" class="cart_header">Price</td>

<td width="220" class="cart_header">Quantity</td>
<td width="80" class="cart_header">Total</td>
<td width="50" bgcolor="#FFFFFF"></td>
</tr>
</table>
<table width="800" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50" bgcolor="#FFFFFF"></td>
<td width="700" class="cart2">&nbsp;</td>

<td width="50" bgcolor="#FFFFFF"></td>
</tr>
</table>

<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr><td width='50' bgcolor='#FFFFFF'></td><td width='300' class='cart2'>Solo Chenille Braided Rug - Cornflower</td><td width='100' class='cart2'>$99.00</td><td width='220' class='cart2'>1</td><td width='80' class='cart2'>$99.00</td><td width='50' bgcolor='#FFFFFF'></td></tr><tr><td width='50' bgcolor='#FFFFFF'></td><td width='700' class='cart2'>5'6'' Round ($60)</td><td width='50' bgcolor='#FFFFFF'></td></tr></table>

<table width="800" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>

<td width="50" bgcolor='#FFFFFF'></td>
<td width="700" class="cart2">&nbsp;</td>
<td width="50" bgcolor='#FFFFFF'></td>
</tr>
</table>[/HTML]

Now here's the PHP code that generates the item line(s) in the above code:

[PHP]
<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'>
<?php

// current session id
$sid = session_id();

$sql = "SELECT *
FROM tbl_cart, inventory
WHERE tbl_cart.pd_id = inventory.id
AND tbl_cart.ct_session_id = '$sid'
";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) == 0) {
echo "<tr>";
echo "<td width='50' bgcolor='#FFFFFF'></td>";
echo "<td width='700' class='cart2'>YOUR SHOPPING CART IS EMPTY</td>";
echo "<td width='50' bgcolor='#FFFFFF'></td>";
echo "</tr>";
} else {
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td width='50' bgcolor='#FFFFFF'></td>";
echo "<td width='300' class='cart2'>";
echo $row['name']."</td>";
echo "<td width='100' class='cart2'>";
echo "$".$row['price'].".00</td>";
echo "<td width='220' class='cart2'>";
echo $row['ct_qty']."</td>";
echo "<td width='80' class='cart2'>";
echo "$".$row['price'].".00</td>"; // Quantity * Price
echo "<td width='50' bgcolor='#FFFFFF'></td>";
echo "</tr>";
if ($row_rs_tbl_cart['ct_opt_a']) {
echo "<tr>";
echo "<td width='50' bgcolor='#FFFFFF'></td>";
echo "<td width='700' class='cart2'>";
echo $row['ct_opt_a']."</td>";
echo "<td width='50' bgcolor='#FFFFFF'></td>";
echo "</tr>";
}
}
}
?>
</table>
[/PHP]

As far as CSS being the problem, the only difference between 'cart2' and 'cart_header' is font size and weight. But just in case, here's that code too:

td.cart2 {
background-color:#F9EFF8;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #1F2E11;
font-size: 12px;
}

td.cart_header {
background-color:#F9EFF8;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #1F2E11;
font-size: 14px;
font-weight: bold;
}

Lastly, I know I'm doing this arse-backwards... just still learning and trying to figure things out.

Anyone see the problem? Thanks in advance.
Nov 27 '07 #1
0 1247

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joy | last post by:
CREATE TABLE my table (coll_a INT NOT NULL, coll_b SMALLINT, coll_c SMALLINT, INDEX b_index (coll_b) ); Above is the table I will created. I declare coll_b and coll_c, which together will...
1
by: Eric | last post by:
Hello, I'm sure your all tired of these "alignment" question, but please endure mine. Question. Simple put: What makes a table sit beside another table, as oppose to going down below it. ...
3
by: Frank Wheeler | last post by:
Why am I unable to attain proper vertical alignment between a DIV and a TABLE here: http://www.whbvillage.com/agenda-archives/agendex.html The DIV is coded: <DIV style="float: left;...
2
by: Nathan Sokalski | last post by:
When using a System.Web.UI.WebControls.Image object, how do I control both vertical and horizontal alignment? Both directions are controlled using the ImageAlign property, which prevents setting...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
6
by: Andy Mabbett | last post by:
Please can someone remind me of the most elegant fix for the way Firefox fails to vertically align cell content by default? For example, the second event on: ...
1
by: jobs | last post by:
I have a content page with a bunch of controls. They are not under a table. I add textboxes and they are won't align left justified like other controls. In Designer they all seem left justified. I...
27
by: pamela fluente | last post by:
Hello, for the following code, VS suggests that construct (width= height= ) is out of date and a newer one is recommended: <table><tr><td width="92" height="38" valign="middle">AnyThing</td></...
15
by: Matthew | last post by:
Hi, I'm mainly a coder, PHP at the moment, but from time to time need to design and use some css. I've a css text alignment issue. Mostly to align text neatly in the past I've used tables....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.