Jump to content

RChilton

Members
  • Posts

    15
  • Joined

  • Last visited

RChilton's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Had to leave this project for awhile but now I am in full swing. All the above makes sense and I can restructure the existing information. The only part I can not get clear in my head is: My original data is being exported from another database. The plan is that the export will have each category path in a separate field something like: SKU Cat1 Cat2 Cat3 Cat4 Cat 5 78000 Candles Ceramics Accents 88000 Bowls Glass Accents 98000 Trays Wood Accents Then from that export I need to put the info into my website database - from the above info with two tables structured like below: Table - categories id name parentid 1 Candles 7 2 Bowls 7 3 Trays 7 4 Ceramics Null 5 Glass Null 6 Wood Null 7 Accents Null Table - prodcat sku id 78000 2 78000 4 78000 7 88000 2 88000 5 88000 7 98000 3 98000 6 98000 7 Assuming I have handled the above category and subcategories properly I can not figure out how to write a prepared statement so that each sku with each individual category gets from the export into the prodcat table. Currently the prepared statement is: //Insert prodcat data using prepared statemnt if product inserted if ($successFlag) { /* create a prepared statement */ if ($stmt = mysqli_prepare($link, "INSERT INTO prodcat (sku, category, codes) VALUES (?, ?, ?)")) { /* bind parameters for markers */ mysqli_stmt_bind_param($stmt, "sss", $data[0], $data[3], $codes); /* execute query */ mysqli_stmt_execute($stmt); // if error if (mysqli_stmt_error($stmt)) { $error = "Product Category Insert Error (" . $data[0] . "): " . mysqli_stmt_error($stmt); errorLog($error); array_push($resultMessage, $error); // if Successful } else { $productsCategoryInsertedCounter++; } /* close statement */ mysqli_stmt_close($stmt); }
  2. So I did not originally develop this database table, but reading more it appears you guys are right on target with what is wrong and what I need to do to correct it. Here is my main question. Currently the field in question can have anywhere between 1-6 different attributes in it that are separated by a comma. How do I get these attributes into their own row with the same sku? I don't have a lot of mysql experience.
  3. I have a MySQL database. The table name is prodcat - it has 3 fields sku, category and codes. Some of the categorys have multiple items in it which is seperated by / for example: Ceramics/Sale Items or just Ceramics in the codes it looks like this: ceramics,saleitems or just ceramics Basically i want to loop through each sku in the prodcat table and every sku that is in ceramics I want it to echo an image. And if that sku is in multiple categories it needs to show the image no matter what category you are in. So if it is a ceramic item that is also on sale I want the image to appear in both those categories I've tried this multiple ways and can get a partial result but can not get it completely the way I want it. Basically I can get it to give me the result in one category but it won't give me the result in both categories. Thanks for the help.
  4. I didn't write the code so I having to dig through it. I do not see anywhere where he actually uses $p = $_GET['p']? The above code does not work. It links but displays nothing....
  5. Here is the pagination function: // Pagination function pagination ($numResults, $activePage, $rangeP) { //Variables $url = selfURL(); //Get Current URL $url = preg_replace('/\&p\=\\d+/', '', $url); $i = 1; //Start loop at 1 $p = $activePage; //P changes in loop $numPages = ceil(($numResults)/($rangeP)); //Total number of pages (result rounded up) if (is_decimal(($numResults/($rangeP))) == false) {$numPages = $numPages;} //Subtracts 1 from numPages if whole number. Fixes extra page error. if ($numPages < 5) {$pagCount = $numPages;} else {$pagCount = 5;} //Pagenation button count. Equal to $numPages if less than $numPages. if ($pagCount == 4) { $offset = $p-1; } else { // Offset account for four pages to correct last active page position if ($p <= 3) { $offset = $p-1; } elseif (($p > 3) && ($p <= $numPages -2)) { $offset = 2; } else { $offset = ($p - $numPages) + 4; }} //Sets offset depending on link position. if ($numPages > 1) { echo("<div class=\"paginationWrap\"><ul class=\"pagination\">"); //Start Display if ($activePage > 2) { echo("<li style=\"border:none; font-size:18px; margin-top:-6px;\"><a href=\"$url&p=1\" class=\"paginationArrows\">«</a></li>"); } if ($activePage > 1) { echo("<li style=\"border:none; font-size:18px; margin-top:-6px;\"><a href=\"$url&p=" . ($activePage-1) . "\" class=\"paginationArrows\">‹</a></li>"); } while ($i <= $pagCount) { echo("<li>"); if ($p-$offset != $activePage) { echo("<a href=\"$url&p=" . ($p-$offset) . "\">" . ($p-$offset) . "</a>");} else { echo ("<b class=\"active\">" . ($p-$offset) . "</b>");} echo("</li>"); $p++; $i++; } if ($activePage < $numPages) { echo("<li style=\"border:none; font-size:18px; margin-top:-6px;\"><a href=\"$url&p=" . ($activePage+1) . "\" class=\"paginationArrows\">›</a></li>"); } if ($activePage < ($numPages-1)) {echo("<li style=\"border:none; font-size:18px; margin-top:-6px;\"><a href=\"$url&p=" . $numPages . "\" class=\"paginationArrows\">»</a></li>"); } echo("</ul></div>"); } }
  6. That is basically how it is written (I did not write the code I'm editing it so I'm a little unfamiliar with how it was all initially setup. Here is the code - "all" feature was not built into it. <?php echo ("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin-bottom:10px; margin-top:2px;\"> <tr> <td width=\"33%\" height=\"30\" style=\"vertical-align:middle;\"> "); breadcrumbs('products',$cat,$p); //Breadcrumbs echo ("</td> <td style=\"text-align:center; vertical-align:middle;\" width=\"33%\">" . (($p*($rangeP))-($rangeP-1)) . " – "); //Page and listing count if (($p*($rangeP)) > ($numResults)) { echo ($numResults); } else { echo ($p*($rangeP)); } echo (" of " . ($numResults) . "</td><td style=\"vertical-align:middle;\" width=\"33%\" > "); pagination($numResults,$p,$rangeP); //Pagination echo ("</td></tr></table> ");
  7. The pagination is at the top - It appears to work properly. it displays like this: Category Name 1-9 of 250 The pagination would obviously have to change if it was showing "view all" too. I need to keep the pages displaying 9 products per page UNLESS someone chooses "view all" link. Trying to figure out how to link "view all" to all the products is the part that I am really stuck on.
  8. Thanks for the help still learning here. I understand how to get it to show all the products - the part I am hung up on is how to get it to show all the products when the "view all" link is clicked. Here is my products_listing.php <?php $url = selfURL(); if (isset($_GET['error'])) { $error = $_GET['error']; } if (isset($_GET['search'])) { $search = $_GET['search']; } if (isset($_GET['related'])) { $related = $_GET['related']; } if (isset($_SESSION['myusername'])){$userName = $_SESSION['myusername'];} else {$userName = NULL;} //************** Product Detail **************** if (!empty($prod)) { if (isProduct($link, $prod)) { require_once('products_listing_detail.php'); } else { echo ("<h1>Sorry! This product ($prod) is not available.</h1> <p>It's either an invalid SKU or the product has been discontinued and is no longer listed.</p> "); } echo ("</div>"); //************** Product Listing **************** } elseif (!empty($cat) && $numResults != 0 ) { require_once('products_listing_listing.php'); //************** Empty Category Listing **************** } else { require_once('products_listing_category.php'); } ?>
  9. Currently on my site it is built to show 9 products at one time on the page. I want to build a view all link that would like to all the products in that particular category. My link is: echo("<a class=\"active\" href=\"$url" . "\">" . "View All</a>"); I can not figure out how to reconfigure the current code to make this happen. Have tried all different avenues have come close but can not get it. Baffled - it seems easy but can not reach the solution. Have attached my current function in my function.php file and my current code that is on the page right now. hyperlink.txt
  10. So I have product images being added to a website the images are named 77777.jpg or 77777-2.jpg for regular photos and then 77777_1, 77777-2_1, 77777-2_2, etc for the set photos. Basically I want to restructure our naming of our photos. Right now the php is using a counter to add the images sequentially. Now I want to name the set images something like 77777_1a, 77777-2_1a and 77777-2_1d. Not sure how to change the counter function to add the photos since they are not sequential any more. The exiting code is below: if (hasAccessByLevel(6, 'LTE', $userName)){ echo ("<ul style=\"margin-top:20px;\"> <li><a href=\"images/productimages/large_$product[sku].jpg\" class=\"largeImage\">Download large image</a> <em>(right click, save as)</em> </li>"); if (file_exists("images/productimages/large_$product[sku]_1.jpg")) { //if set photo exists $counter = 0 ; foreach (glob("images/productimages/large_$product[sku]_*.jpg") as $filename) { //Loop through set photos if($counter++ < 0) continue ; echo ("<li><a href=\"images/productimages/large_$product[sku]_$counter.jpg\" class=\"largeImage\">Download large set photo</a> </li>"); } } echo ("</ul>"); }
  11. I am editing some existing code. Trying to add a 3rd layer to the left sidebar product category navigation basically a subsubmenu item. The code was already written, however something is wrong in the functionality. Couple of issues. Category items with sub menus function correctly (such as the essentials category). Categories with two sub menus (boutique) functioning but here are the issues. 1. Subcategory has to have product in it for sub sub categories to show up. Where as in the other categories this is not the case. 2. Sub Sub Categories automatically expand all the way out when you hit the main category. It should function that the sub sub categories do not expand until the subcategory is clicked. I've worked it several different ways but can not come up with the correct combination to make it function properly. Attached the php page with link to the site on top. Thanks for the help... products_nav2.php
  12. Okay I think I figured it out.... Replaced: $related=preg_replace("/[^a-zA-Z0-9|]/", "", $product['related']); With: $related=preg_replace('/[^A-Za-z0-9|() -]/', '', $product['related']);
  13. I have a field being imported from a .txt file. Each field has multiple ^ characters which need to be removed then each different sku in the field is separated by | to indicate a new sku. Some of the sku's have hyphens example 12345-6. As the code is written these skus do not show up because it is stripping the hypen out too and then it is an ureconizable sku. Currently the code is: $related=preg_replace("/[^a-zA-Z0-9|]/", "", $product['related']); $relatedrestricted = array('hospitalitymirrors', 'hospitalityaccessories', 'hospitalityfurniture', 'hospitalitylighting'); if (!empty($related) && !in_array($cat, $relatedrestricted)){ $relatedItems = explode("|", $related); echo ("<tr> <td colspan=\"2\"> <h2>Related Products</h2> <ul id=\"relatedItems\"> "); foreach($relatedItems as $relatedItem) { if (isProduct($link, $relatedItem)) { echo ("<li> <a href=\"products.php?prod=$relatedItem&related=true\"> <img src=\"images/productimages/thumb_$relatedItem.jpg\" alt=\"View " . getName($relatedItem) . "\"/><br /> $relatedItem<br /> " . getName($relatedItem) . " </a> </li> "); } }
  14. I understand where you are going with this code. I jus can not seem to incorporate it into the existing code and get it to work.
  15. I have a php shopping cart that I am editing that someone else developed. My php skills are still very beginner. Currently the customer must order $500 to place an order if their cart contains less they get a message - order must be $500. They want this to change so that any items that are in the categories of (accessories, scarves and jewelry) ONLY have a min order total of $150 but ALL other items in the other categories STILL have a min order total of $500. So in summary I need it to check if there are any items in accessories, scarves and jewelry - the total of those items OLY needs to be $150 if not a message needs to be displayed "boutique items have $150 min order." Then I need it to check all other items in the cart and those items ONLY need to total $500 or a message needs to be displayed "$500 min order required". There is a lot of other code mixed in with the current orderDetails page about coupons, etc which is throwing me off a little. I have attached a copy of orderDetails page so you could have all the code. I have also attached a screenshot of the cart page since it is unavailble for viewing unless you have a login. Thanks for the help. I need to get this fixed ASAP...I have gotten close a few times but just can not get it exact. orderDetails.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.