1

I am trying to print out on my sites home page a horizontal table which includes a picture of a car and then below the make, model & price of the car.

Here's roughly what I have done:

<?php 
$List = "";
$sql = mysql_query("SELECT * FROM Car ORDER BY listed DESC LIMIT 5");

$Count = mysql_num_rows($sql);
if ($Count > 0) {
    while($row = mysql_fetch_array($sql)){
        $id = $row["id"];
        $make = $row["make"];
        $model = $row["model"];
        $price = $row["price"];

        $List .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
        <tr>
        <td width="20%" valign="top"><a href="/motors/cars.php?id=' . $id . '"><img style="border:#666 1px solid;"
        src="/../../motors-' . $id . '.jpg" alt="' . $status . ' ' . $title . '" width="100" height="80" border="1" /></a></td>
        </tr>

        <tr>
        <td width="80%" valign="top" align="left"><font face="Arial" color="#000080"><B>
        ' . $make . ' ' . $model . '</B></font><br />' . $price . '

        <a href="/motors/cars.php?id=' . $id . '">view car details</a></align></td>
        </tr>
        </table>';
    }
} else {
    $List = "No cars at present";
}
mysql_close();
?>

Can anyone help me sort this code to print out horizontally? Many Thanks!

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123

1 Answers1

0

The src of the image is most likely wrong, /../../motors... is still /motors...

you can move the images into your webapps /motors/images folder and set src as /motors/images/motors...

The table you create must be nested in another table.

<table>
    <tr>
        <td>
            <table of a car>
        </td>
       <td>
            <table of a car>
        </td>
        <td>
            <table of a car>
        </td>
        .... etc.
    </tr>
</table>

It will make sense to emit a tr every few cars to wrap to a new line.

table of a car is the html you collect in $List.

thst
  • 4,592
  • 1
  • 26
  • 40