Php css float help

hello,

im trying to get my records to display along side of each other but i dont know what im doing wrong as its only showing then underneath each another as you can see here http://www.mabrodie.co.uk
can anyone help me please?

<?php 

// Run a select query to get my letest 6 items

// Connect to the MySQL database  

include "storescripts/connect_to_mysql.php"; 

$dynamicList = "";

$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");

$productCount = mysql_num_rows($sql); // count the output amount

if ($productCount > 0) {

	while($row = mysql_fetch_array($sql)){ 

             $id = $row["id"];

			 $product_name = $row["product_name"];

			 $price = $row["price"];

			 $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));

			 $dynamicList .= '<table width="100%" border="0" cellspacing="35" cellpadding="6">

        <tr>

          <td width="17%" valign="top"><</td>

          <td width="83%" valign="top">' . $product_name . '<br />

            $' . $price . '<br />

            <a href="product.php?id=' . $id . '">View Product Details</a></td>

        </tr>

      </table>';

    }

} else {

	$dynamicList = "We have no products listed in our store yet";

}

mysql_close();

?>

Where’s the CSS code?
It looks like you have all three tables in one div:

image

What happens if you put each table inside it’s own div, and then float the divs left or use flexbox/grid? Another option would be to not use tables at all. Have a container div with a left div for the image and a right div for the link and description.

Okay, I did some messing around. You used float: right many times.
Here’s what I ended up with:
image

Here are screen shots of the CSS in Firefox Dev Tools.

image

image

image

NOTE: Display set to flex. This line alone arranges the tables into a single row. It avoids the need for many floats and clears.
image

hello,

ive tried using divs but it dosent seem to work inside the $dynamicList = “”;?

Sponsor our Newsletter | Privacy Policy | Terms of Service