Hello, Just want to ask help for php programmers. I have a problem alligning my product, actually i'm trying to display the product that's query in mysql display it in two column. here's my code: $left = true; while($fetched=mysql_fetch_array($result)) { if ($left) { echo "<table><tr>"; } echo "<td align='justify' width='35%' cellspacing='2' cellpadding='2' >"; echo "<div class='xdiv' id='xborder'><table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td colspan='2' valign='top' height='20' background='images/bg.jpg' class='whiteBold'><a name=".$fetched['product_name']."></a> ".$fetched['products_name']."<br></td> </tr> <tr> <td width='22%' rowspan='2' valign='top'><img src=".$fetched['product_imagepath']." width='120' height='100' style='border:1px #323335 solid;'></td> <td width='78%' valign='top'><span class='redFont'>Description: </span><span class='normaltext'>".$fetched['product_description']."</span></td> <tr> <td valign='middle'><span class='redFont'>Price: </span><span class='normaltext'>".$fetched['price']."</span></td> </table></div>"; echo"</td>"; if (!$left) { echo"</tr>"; } $left = !$left; } echo"</table>"; PHP: the actual view in the page: anyone can debug my code, just want to align the display in two column. please help.. thanks
Has nothing to do with PHP but everything to do with your generated HTML. YOu should post this in the HTML/CSS section.
Try to use div with style="float: left" instead of using tables. Check this code: <?php echo '<div style="float:left">'; while($fetched=mysql_fetch_array($result)) { echo '<div class="xdiv" id="xborder" style="float: left">'; echo "<table width='200px' border='0' cellspacing='0' cellpadding='0'> <tr> <td colspan='2' valign='top' height='20' background='images/bg.jpg' class='whiteBold'><a name=".$fetched['product_name']."></a> ".$fetched['products_name']."<br></td> </tr> <tr> <td width='22%' rowspan='2' valign='top'><img src=".$fetched['product_imagepath']." width='120' height='100' style='border:1px #323335 solid;'></td> <td width='78%' valign='top'><span class='redFont'>Description: </span><span class='normaltext'>".$fetched['product_description']."</span></td> <tr> <td valign='middle'><span class='redFont'>Price: </span><span class='normaltext'>".$fetched['price']."</span></td> </table>"; echo "</div>"; } echo "</div>"; ?> PHP: Formatted code here: http://shortwebsite.com/0de482