Jump to content

greg

Members
  • Posts

    48
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

greg's Achievements

Member

Member (2/5)

0

Reputation

  1. That approach is not easy. A database with 13,000 products and more than 40 pages already pulling the color names are something to consider if new code is in place. The colors are stored in a field, in the table products, one row per product, separated by commas and some products may have no colors at all. Until now we only pulled names and wont run in trouble. We are now looking to add a visual color in the listing. This is not to pull the data for a specific product but for a category of product where the list is 40-200 products. $totalviewColors is defined in the listing query and the reason is because I don't want to run a code for products with no colors at all. How the color names and color codes in $item_colorsCODE[] are pushed out of the loop?
  2. Hi Psycho, First - Understood Second - In this case IS NULL, I mean does not exist in table. Third - No, is not the output of the string. I have a list of colors of each product which is $totalviewColors. The count is different for each product, for example: Product A --> Blue, Red, Green, White --> $totalviewColors= 4 Product B --> Red, Black, Gray --> $totalviewColors= 3 Now, I have color_charts_colors with an structure like this: ID | color name | color code 1 | Blue | #0000FE 2 | Red | #9E2337 3 | Green | #008A59 4 | Gray | #56595C 5 | White | #FFFFFF As you can see, Black is not in this table. That is the NULL. Why is NULL? Because Black is in the list of colors for Product B, but there is no reference in the table color_charts_colors for this color name. so $countColors will be this: Product A --> $countColors= 4 Product B --> $countColors= 2 Do you understand now the structure? What I want is to take the color codes of the color names existing in the table and output columns using the color code as a background. Have you seem these small squares showing the color of products on some websites? That is what I looking for. I tested your code and got this error: Parse error: syntax error, unexpected '" AND id NOT NULL ' (T_CONSTANT_ENCAPSED_STRING) Thank you!
  3. @Psycho, yes, that's right. I also tried array_filter() without luck. This is the complete code. Because not all $product_view_color have id, how can I run the query only IF NOT NULL? $countColors = 0; $ItemString = ''; for($i=0; $i<$totalviewColors; $i++){ $result9 = mysql_query("SELECT id, color_name AS name, color_code AS code, COUNT(*) FROM color_charts_colors WHERE color_name = '".trim($product_view_color[$i])."' ORDER BY color_chart_id DESC LIMIT 1"); if(mysql_num_rows($result9)>0){ $rowscode = mysql_fetch_assoc($result9); $item_colorsCODE[] = $rowscode; if($i!=$totalviewColors-1){ $ItemString .= "'".$rowscode['id']."', "; } else { $ItemString .= "'".$rowscode['id']."'"; } $countColors++; } } }
  4. How can I remove the blank entries? Tried trim() and doesn't work. $string = '178', '1', '179', '', '180', '67', '63', '47', '46', '', '', '', '201'; Thanks
  5. I have the following array. Some values are in more than one group meaning that color belongs to more than one product. array (size=6) 0 => string 'Beige' (length=5) 1 => string 'Blue' (length=4) 2 => string 'Green' (length=5) 3 => string 'Red' (length=3) 4 => string 'White' (length=5) 5 => string 'Yellow' (length=6) array (size=6) 0 => string 'Black' (length=5) 1 => string 'Blue' (length=4) 2 => string 'Natural' (length=7) 3 => string 'Red' (length=3) 4 => string 'White' (length=5) 5 => string 'Yellow' (length=6) array (size=12) 0 => string 'Black' (length=5) 1 => string 'Burgundy' (length= 2 => string 'Blue' (length=4) 3 => string 'Green' (length=5) 4 => string 'Gold' (length=4) 5 => string 'Orange' (length=6) 6 => string 'Purple' (length=6) 7 => string 'Red' (length=3) 8 => string 'Silver' (length=6) 9 => string 'Teal' (length=4) 10 => string 'White' (length=5) 11 => string 'Yellow' (length=6) How can be merged in a way to get all values together and finally get these values counted so can get the result as seem at the end? array (size=24) 0 => string 'Beige' (length=5) 1 => string 'Blue' (length=4) 2 => string 'Green' (length=5) 3 => string 'Red' (length=3) 4 => string 'White' (length=5) 5 => string 'Yellow' (length=6) 6 => string 'Black' (length=5) 7 => string 'Blue' (length=4) 8 => string 'Natural' (length=7) 9 => string 'Red' (length=3) 10 => string 'White' (length=5) 11 => string 'Yellow' (length=6) 12 => string 'Black' (length=5) 13 => string 'Burgundy' (length= 14 => string 'Blue' (length=4) 15 => string 'Green' (length=5) 16 => string 'Gold' (length=4) 17 => string 'Orange' (length=6) 18 => string 'Purple' (length=6) 19 => string 'Red' (length=3) 20 => string 'Silver' (length=6) 21 => string 'Teal' (length=4) 22 => string 'White' (length=5) 23 => string 'Yellow' (length=6) Final Result Beige (1) Black (2) Blue (3) Burgundy (1) Gold (1) Green (2) Natural (1) Orange (1) Purple (1) Red (3) Silver (1) Teal (1) White (3) Yellow (3) Greg
  6. Hi, How can I extract from the variable $requestedimage only the image name? $requestedimage = $_GET['pID']; I appreciate if someone can give me a hand on here. Thanks images/9998/bar3400.gif >>>> extract bar3400.gif images/20125/gt23122.gif >>>> extract gt23122.gif images/202/gr_open453.gif >>>> gr_open453.gif images/2021/hllleat875.jpg >>>> hllleat875.jpg
  7. I'm trying to get the number of rows of each group after gouping products_quantity_order_min using the following query but the results are not accurate. Any idea? Thanks $qty_min ="SELECT p.products_quantity_order_min, p.products_price, p.products_rush_service, pd.products_name, COUNT(*) AS `count` from products p left join products_description pd on p.products_id= pd.products_id where p.products_rush_service = 1 group by products_quantity_order_min order by products_quantity_order_min asc";
  8. Thank you. I get it working with this: require_once($_SERVER["DOCUMENT_ROOT"] . "/configure.php"); The best!
  9. How to include root files from subdirectory in php? I have tried include '../configure.php'; but got error. Also tried include($DOCUMENT_ROOT."../configure.php"); but same result. For example, I have "root/admin" directory, and can't connect (from "/admin" dir) to the file configure.php which is in root. There are also other files to include.
  10. This is exactly what I needed! - Thank you for your help.
  11. Yes, I need something like this: Apple store (5) Boy t-shirt (56) Girls stuff (45) Php code (5) Windows mobile (1) Where the words are the keywords and the numbers is the count. Thank you!
  12. Hello everyone, Could be possible someone help me on this code please? I need to group and sort $search_query. They are the keywords extracted from $_SERVER[HTTP_REFERER] (referer in the query). Thank you in advance. $query = ("SELECT referer, browser_ip, date, customers_id, counter, browser_id, browser_language FROM visitors WHERE SUBSTRING(browser_language,1,1) != '[' ORDER by date DESC"); $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $referer = $row[0]; IF($referer) { PREG_MATCH("/[\&\?]q=([^&]*)/", $referer, $matches); $search_query = RAWURLDECODE($matches[1]); $search_query = STR_REPLACE("+", " ", $search_query); } ........................
  13. Thank you!!!!! Like I said, jkaiosdaxcss
  14. How I do that when the referring pages are dynamic?
×
×
  • 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.