473,775 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP code destroying the alignment of my table???

40 New Member
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_c art.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="#FFFFF F"></td>
<td width="700" class="cart_hea der">Your Shopping Cart</td>
<td width="50" bgcolor="#FFFFF F"></td>
</tr>
</table>
<table width="800" align="center" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="50" bgcolor="#FFFFF F"></td>

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

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

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

<table width='800' border='0' align='center' cellpadding='0' cellspacing='0' >
<tr><td width='50' bgcolor='#FFFFF F'></td><td width='300' class='cart2'>S olo 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='#FFFFF F'></td></tr><tr><td width='50' bgcolor='#FFFFF F'></td><td width='700' class='cart2'>5 '6'' Round ($60)</td><td width='50' bgcolor='#FFFFF F'></td></tr></table>

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

<td width="50" bgcolor='#FFFFF F'></td>
<td width="700" class="cart2">& nbsp;</td>
<td width="50" bgcolor='#FFFFF F'></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_ses sion_id = '$sid'
";
$result = mysql_query($sq l) or die(mysql_error ());
if (mysql_num_rows ($result) == 0) {
echo "<tr>";
echo "<td width='50' bgcolor='#FFFFF F'></td>";
echo "<td width='700' class='cart2'>Y OUR SHOPPING CART IS EMPTY</td>";
echo "<td width='50' bgcolor='#FFFFF F'></td>";
echo "</tr>";
} else {
while ($row = mysql_fetch_arr ay($result)) {
echo "<tr>";
echo "<td width='50' bgcolor='#FFFFF F'></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='#FFFFF F'></td>";
echo "</tr>";
if ($row_rs_tbl_ca rt['ct_opt_a']) {
echo "<tr>";
echo "<td width='50' bgcolor='#FFFFF F'></td>";
echo "<td width='700' class='cart2'>" ;
echo $row['ct_opt_a']."</td>";
echo "<td width='50' bgcolor='#FFFFF F'></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 1260

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

Similar topics

1
1462
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 cose me 4 bytes in one row. Is it? What if I declare both of them as INT, will it cost me more memory? How about the
1
2096
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. Here's my example ... <html>
3
4285
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; background: transparent; color: #000099;
2
1815
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 both a vertical and horizontal direction. Why isn't there something like a VerticalAlign and HorizontalAlign like the System.Web.UI.WebControls.TableCell object? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
1
2368
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. -- .. http://sf-f.org, weblog and search engine for fans and writers of
6
7873
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: http://www.westmidlandbirdclub.com/diary/ Thank you. --
1
1590
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 look at the html rendered and can't explain this alignment ??? I'm running asp.net 2.0 and I.E. 6.0. the control in question is : ctl00$ContentPlaceHolder1$DateFilter snip..
27
2839
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></ tr></table> Would you please tell me the right construct (clearly must be functionally equivalent).
15
2718
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. But now I know I should be getting into the 21st C and using css properly. Here are 2 mock up pages with some forms on them, obviously I want the
0
10270
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10051
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.