Page 1 of 1

How to do this display using php and mysql

Posted: Sat Feb 25, 2006 4:03 pm
by Homeboy
Hello,

I want to be able to do something like this on the costco website
http://www.costco.com/Common/Category.a ... |1133|2512

I have pictures that i like to put a price of it on the right side and then have a description of it on the third column.

So basically have 3 columns on a row, 1 column have the picture, 2 column have the the price information and the 3 column have the description of it. How can i achieve this?

Thanks,

Homeboy

Posted: Sat Feb 25, 2006 6:23 pm
by pennythetuff
First off don't store actual pictures in your database. Just store the address to the picture which should be located in an images folder somewhere on your server. Just to let you know in case you are doing this.

Here's a way you could do it.


Code: Select all

$query = "...";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);

for($a = 0; $a < count($row); a++) {
     echo "<img src=\"" . $row['picture_row'] . "\" />";
     echo "Price Information: " . $row['price_information'];
     echo "Description: " . $row['descrip'];
}
Of course you could replace the echo's with variables, and the $row index's with your actual column names in your database. Have you worked with PHP and MySQL before? The example above is assuming you have. If you haven't then check out the PHP documentation on PHP's site (http://www.php.net). Here's a link to their MySQL functions. http://us3.php.net/manual/en/ref.mysql.php.