Jump to content

Displaying database information in columns


Wardy_7

Recommended Posts

I have a database with products in and I want iT to automatically show every product on the page. Now I am able to do this easy enough but what I am struggling to do is that I want the products to be displayed in 3 columns. I can get them to display one under the other easy enough but I want them to be in rows with 3 columns instead.

 

Can anyone please help.

 

echo("<table>"); 
      
    while($row = mysql_fetch_array($result)){ 
        if ($bgcolor == "#F7DF42"){ 
            $bgcolor = "#FFFFFF"; 
        }else{ 
            $bgcolor = "#F7DF42"; 
     } 
    echo("<tr bgcolor=".$bgcolor.">\n<td>"); 
    echo('<a href="../products/' . $row["product_code"] . '">' . $row["description1"] . '</a>'); 
    echo('<img src="' . $row["small_image"] . '" alt="' . $row["description1"] . ' ' . $row["description2"] . '"></a>'); 
    echo("</td>\n"); 
    } 

    echo("</table>");

 

Cheers

Wardy

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.