Jump to content
Larry Ullman's Book Forums

Jane39

Members
  • Content Count

    17
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Jane39

  • Rank
    Newbie
  1. It's fine Hartley as I messed things up. I will keep looking around for the answer and let you know if I found one. I just have one more question. In the php code mentioned above, is it possible to define the array "$color_palettes[$ii]" before the <td> tag (without changing the html output)? So that way I can use it in the src attributes of the .main class instead of within .toggles class only. Thanks
  2. I pressed F12 (Ctrl+Shift+J) while I'm on the link page and found this. event.returnValue is deprecated. Please use the standard event.preventDefault() instead. panel-1 category.php?category=Dresses:75 Is it the way of viewing the console in browser? This line (panel-1....) comes from another function that I'm using on a navigation bar. I'm placing it within the <body> tag and it's working. As I mentioned, hover function on ProductImage is working but on colors isn't working even I'm putting them in the same place (within the <head> tag as a link). I hope this could tell you something. Otherwise, do you think there's something wrong in my php parts? Please let me know if there's anything I could do to trace the errors. Thanks Hartley.
  3. I had copied and pasted exactly what you gave me into my code but I still didn't see errors in the browser. I think I don't know how to view the console but I will google it now. I'm using Chrome as my browser.
  4. I copied your example as above and replaced the current one in my javascript file but still see no errors in the browser. I think my problem is probably from php code. From select statement I posted in category.php section, you would see I created two columns related to colors; one is called "color_palette" and the other is "color_palettes" which is group concat by all "color_palette" of each product id. Within .main class, each variable "$color_palette" I'm using in the src attributes is from column "color_palette". And within .toggles class, each array "$color_palettes[$ii]" in src attrbutes is from the other column, "color_palettes". When I mouse over each color, the alternate image for each color doesn't show up because each $color_palettes[$ii] does not exist in .main class of the img tag I think. Any ideas please?
  5. This is generated HTML Hartley. I spaced them for an easier view. <table><tr> <td><div class="image"> <a href="product.php?id=2&colorpalette=JJ2BGXX"><img class="main" data-alt-src="images/1431.JJ2BGXX.BR.jpg" src="images/1431.JJ2BGXX.FR.jpg" width="300" height="327" /></a><br /> <div class="toggles"> <a href="product.php?id=2&colorpalette=JJ169XX"><img data-src="images/1431.JJ169XX.FR.jpg" src="images/1431.JJ169XX.CP.jpg" /></a> <a href="product.php?id=2&colorpalette=JJ2BGXX"><img data-src="images/1431.JJ2BGXX.FR.jpg" src="images/1431.JJ2BGXX.CP.jpg" /></a> </div> </div></td> <td><div class="image"> <a href="product.php?id=3&colorpalette=JJ2EUA0"><img class="main" data-alt-src="images/1791.JJ2EUA0.BR.jpg" src="images/1791.JJ2EUA0.FR.jpg" width="300" height="327" /></a><br /> <div class="toggles"></div> </div></td> [same generated for product id 5] <td><div class="image"> <a href="product.php?id=6&colorpalette=JJ8BSA4"><img class="main" data-alt-src="images/4867.JJ8BSA4.BR.jpg" src="images/4867.JJ8BSA4.FR.jpg" width="300" height="327" /></a><br /> <div class="toggles"></div> </div></td> </tr><tr> [same generated for product id 7] <td><div class="image"> <a href="product.php?id=8&colorpalette=JJFR4A1"><img class="main" data-alt-src="images/5375.JJFR4A1.BR.jpg" src="images/5375.JJFR4A1.FR.jpg" width="300" height="327" /></a><br /> <div class="toggles"> <a href="product.php?id=8&colorpalette=JJC88A2"><img data-src="images/5375.JJC88A2.FR.jpg" src="images/5375.JJC88A2.CP.jpg" /></a> <a href="product.php?id=8&colorpalette=JJC50XX"><img data-src="images/5375.JJC50XX.FR.jpg" src="images/5375.JJC50XX.CP.jpg" /></a> <a href="product.php?id=8&colorpalette=JJFR4A1"><img data-src="images/5375.JJFR4A1.FR.jpg" src="images/5375.JJFR4A1.CP.jpg" /></a> </div> </div></td> </tr></table>
  6. There's no errors shown up in the browser. I put javaScript in a separate file and link it at the <head> part of html. Hover function on ProductImage is working, but the other is not Hartley.
  7. Hartley, I will store the alternate image for each color later. I did have a column for images, but also when I tried to combine variables $style & $color to create names and links for images and it worked. So I thought I would go with it as that way i don't have to create another table for images. The alternate images and colors still work when I switched the code a little bit but somehow hover function on colors are not working. Here are my javascript. //Hover function on ProductImage var sourceSwap = function () { var $this = $(this); var newSource = $this.data('alt-src'); $this.data('alt-src', $this.attr('src')); $this.attr('src', newSource); } $(function () { $('img.main').hover(sourceSwap, sourceSwap); }); // Hover function on colors $('.image .toggles img').hover(function () { var src = $(this).attr("data-src"); var $main = $(this).closest(".image").find(".main"); $main.attr("toggle", $main.attr("src")).attr("src", src); }, function () { var $main = $(this).closest(".image").find(".main"); $main.attr("src", $main.attr("toggle")); });
  8. 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.
  9. I finally managed to get all products and their available colors displayed on the page Hartley. It took me a lot of days before I figured it out, and now I feel super happy because I can move to the next step. Thanks
  10. Awesome Hartley. I made the php files work finally. It's my fault when I didn't create stored procedures as guidance in Larry's book at first. You're always helpful Hartley. Thank you.
  11. I totally agreed with you about the DB design Hartley and I think I did the same thing. Here are how my tables look like. tblProducts tblSizes tblColors tblImages tblSpecific_Products id id id id id product_name size color image product_id (FK) style_code size_id (FK) price color_id (FK) image_id (FK) My question is how do I display all available colors on the general products page as you mentioned? See a sample picture of a product page for what I mean here. http://s12.postimg.org/l8s0zh4d9/product_page_sample.png. Thanks Hartley.
  12. Hi Hartley, Regarding step 1 as you mentioned, I tried but still couldn't get all available colors to display on the product page. How do I have those colors in colors table to display on the product page? Do I have to create another attribute table for colors and products tables? Right now I have products table, colors table, sizes table, images table and specific_products table (product_id FK, color_id FK, size_id FK, image_id FK). What I've done now is I had all items displayed on the page. Each item has a default (front-view) image and a hidden (back-view) image. So when users hover their mouses over any default image, the hidden one will be showed. Thanks.
  13. I'm running PHP files of example 2 from my computer and I got those following errors across pages. An error occurred in script 'D:\XAMPP\htdocs\ex2\html\views\home.html' on line 14: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\shop.php' on line 32: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\sales.php' on line 20: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\wishlist.php' on line 80: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\cart.php' on line 81: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array Can someone please tell me how to fix it? Thanks.
  14. I'll follow your recommendation and let you know after trying it Hartley.
×
×
  • Create New...