I have a blank trying to figure out how to do the following. I have 2 tables tbl_products tbl_prdtimages and I need to run a loop through both of these to get a thumb nail image and the product_ID to pass through the URL to my results page. I can get most of this working however the image that I’m getting is the first from the database which means the loop is only being applied to the tbl_products table and ignoring the tbl_prdtimages table. I have a working example here and you can see the same image listed throughout however once each item is clicked the correct id is passed to the results page. So can anyone give me a few pointers as to how I can loop through both tables.
http://www.batchelorscoffeecompany.ie/b ... mages3.php
This is the code from the page.
Many thanks
Code: Select all
<?php
mysql_select_db($database_*****, $*******);
$query_GetImages = "SELECT * FROM tbl_products,tbl_prdtimages
WHERE tbl_prdtimages.prdctImage_ImgTypeID = '1'
GROUP BY tbl_products.product_ID";
$GetImages = mysql_query($query_GetImages, $b******) or die(mysql_error());
$row_GetImages = mysql_fetch_assoc($GetImages);
$totalRows_GetImages = mysql_num_rows($GetImages);
?>
<?php do {
<a href="details.php?prodId=<?php echo $row_GetImages['product_ID']; ?>"><img src="cw3/assets/product_thumb/<?php echo $row_GetImages['prdctImage_FileName']; ?>" alt="<?php echo $row_GetImages['product_ShortDescription']; ?>" border="0" > <br><?php echo $row_GetImages['product_ShortDescription']; ?></a><br><br>
<?php } while ($row_GetImages = mysql_fetch_assoc($GetImages)); ?>