Forum Moderators: coopster
In a webshop which im working on there is the possibility that one product is available in different colors. These products have to be inserted sepreately beacuse they have different EAN codes and are basically different products.
However, for the visitor it might be interesting to show pictures of these similar products with different colors. I already created a field called "groupnumber" where the same number is filled in for every color of the same product type.
I dont know however how to create (a new recordset?) a way to show the images of these products.
variables used in the database:
- id --> unique numbe which is also the "image name". So an image is loaded like this: /images/<?php echo $row_Recordset1['id']; ?>.jpg
- groupnumber
All products are stored in the same table called "product".
Please let me know what you think would be the best way.
Kind regards,
Nick.
($variable_with_the_group_number --> this isnt how it should be inserted right?)
Thanks.
Look at the library topics I linked to in your other thread, especially the one on extracting data from mysql.
Code:
<?php if($row_Recordset1['groepnummer']) {
$query = mysql_query("SELECT id, naam, categorie, subcategorie, slug FROM product WHERE groepnummer={$row_Recordset1['groepnummer']}");
if(mysql_num_rows($query)) {
while($rec = mysql_fetch_row($query))
echo "<a href='/".str_replace(array('%20', ' '), '-', $rec[2]) ."/".str_replace(array('%20', ' '), '-', $rec[3]) ."/".str_replace(array('%20', ' '), '-', $rec[4]) ."/'><img src=\"/images/thumb/{$rec[0]}.jpg\" height='40' width='40' border='0' alt='".$rec[2]." » ".$rec[1]."'></a> ";
}
}
?>