Search the Community
Showing results for tags 'colors'.
-
Change Another Image On Link Hover
Jane39 posted a topic in Effortless E-Commerce with PHP and MySQL
Hi, My product page (output) in HTML is something like this: ProductImage1 ProductImage2 ProductImage3 ProductImage4 Color1 Color2 Color3 Color4 Color2 Color5 Color6 What I'm trying to do is when I hover my mouse over any color above, an original (main) image of ProductImage will switch to another image (to match the hovered color). And that original image will be back when the mouse leaves. Example: http://jsfiddle.net/4dK2x/27/ I also added another hover function on ProductImage for switching images between front view and back view and it's working well. (You would see the two src attributes of the .main class image in my php code as follows) However, the hover function on colors is not working when I run php code to create a dynamic list. Here are my category.php. ---- $sql = mysqli_query($db_connect, "SELECT p.id,p.style,c.color_palette, GROUP_CONCAT(DISTINCT CONCAT(c.color_palette) ORDER BY p.id SEPARATOR '+') color_palettes FROM product_details AS pd INNER JOIN products AS p ON p.id=pd.product_id INNER JOIN colors AS c ON c.id=pd.color_id INNER JOIN subcategories AS sub ON sub.id=p.subcategory_id INNER JOIN categories AS cat ON cat.id=sub.category_id WHERE category='$category' GROUP BY p.id LIMIT 6"); [...] $i= 0; $Output= '<table><tr>'; while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ $id = $row["id"]; $color_palette = $row["color_palette"]; $style = $row["style"]; $color_palettes = explode("+", $row["color_palettes"]); $Output.= '<td><div class="image"><a href="product.php?id='.$id .'&colorpalette='.$color_palette.'"><img class="main" data-alt-src="images/'.$style.'.'.$color_palette.'.BR.jpg" src="images/'.$style.'.'.$color_palette.'.FR.jpg" width="300" height="327"/></a><br />'; $Output.= '<div class="toggles">'; for ($ii=0;$ii<count($color_palettes);$ii++){ if (count($color_palettes) > 1) { $Output.= '<a href="product.php?id='.$id .'&colorpalette='.$color_palettes[$ii].'"><img data-src="images/'.$style.'.'.$color_palettes[$ii].'.FR.jpg" src="images/'.$style.'.'.$color_palettes[$ii].'.CP.jpg" /></a> '; } else { $Output.= '';} } // End for loop $Output.= '</div>'; $Output.='</div></td>'; $i++; if ($i%4==0){ $Output.= '</tr><tr>';} } // End while loop $Output.= '</tr></table>'; ---- I think my problem is probably because the array $color_palettes[$ii] is not defined in .main class image. So if that i the case, what do I do to fix it? Any help would be much appreciated.- 15 replies
-
- javascript
- colors
-
(and 2 more)
Tagged with: