Hello,
I have research as many tutorial possible on how to get this done, but it's still not there.. below is my code right now:
$query = mysql_query("SELECT * FROM products, products_description, products_image WHERE products.products_id = products_description.products_id AND products.products_id = products_image.products_id AND products_description.language_id = 4 AND products.products_status = 1 ORDER BY products.products_last_modified desc");
while($row = mysql_fetch_array($query))
{
if($row[products_special_image] != null)
$row[products_image_id] = $row[products_image_id] + 1;
echo "<font size=1>".$row['products_id'] . " | " .$row['products_name']. " | " .$row['products_head_title_tag'] ." | " .$row['products_last_modified'] ." | " .$row['language_id']." | " .$row['products_image_id']. "</font>";
echo "<br /><br/>";
This is what ultimately I want to achieve:
there are 3 tables:
1. products
2. products_description
3. products_image
field products_id is common in all 3 tables. THe problem I have is to show the correct image. In table 'products_image', each products_id may have up to 5 images (see image http://lh5.ggpht.com/_wkgy6rQWRGI/ScdAWBopzlI/AAAAAAAAAPo/dYPFtKWhnpk/tablesample.jpg )
now the image I want to show is ONE of the field 'product_image', its product_image_id equals to where products_special_image is NOT NULL, product_image_id + 1...
for example, for products_id 4, the image I want to show has products_image_id = 7, and for products_id 2, products_image_id = 11, and so on...
with the code I have right now (without echoing the image, just the product_image_id), I get repeated rows as many times as there are repeated products_id within the products_image table..
I hope this makes sense, any help is very much appreciated!