help with my product page

Discussion in 'PHP' started by cris02, Sep 24, 2009.

  1. #1
    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>&nbsp;".$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:&nbsp;</span><span class='normaltext'>".$fetched['product_description']."</span></td>
          <tr>
            <td valign='middle'><span class='redFont'>Price:&nbsp;</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:
    [​IMG]

    anyone can debug my code, just want to align the display in two column. please help.. thanks
     
    cris02, Sep 24, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Has nothing to do with PHP but everything to do with your generated HTML. YOu should post this in the HTML/CSS section.
     
    premiumscripts, Sep 24, 2009 IP
  3. Martinoes

    Martinoes Peon

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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>&nbsp;".$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:&nbsp;</span><span class='normaltext'>".$fetched['product_description']."</span></td>
    		      <tr>
    		        <td valign='middle'><span class='redFont'>Price:&nbsp;</span><span class='normaltext'>".$fetched['price']."</span></td>
    		      </table>";
    	echo "</div>";
    }
    
    echo "</div>";
    
    ?>
    PHP:
    Formatted code here: http://shortwebsite.com/0de482
     
    Martinoes, Sep 24, 2009 IP
  4. cris02

    cris02 Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    Thank you, its look nice now. :)
     
    cris02, Sep 24, 2009 IP