Jump to content

greg

Members
  • Posts

    48
  • Joined

  • Last visited

Posts posted by greg

  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. 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

     

  5. 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

  6. 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";

  7. 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.

  8. 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);
    }
    
    ........................
    
    

  9. The attached query works perfectly, only that I need something extra and after 5 hours, I think it is time to look for help.

     

    There are two tables I need to incorporate.

    table custom_options (fields custom_options_id and heading)

    table custom_options_products (fields custom_options_id and products_id)

     

    I need to get the heading from the table custom_options where custom_options.custom_options_id = to  custom_options_products.custom_options_id and custom_options_products.products_id = products_id and products_id are the products_id for products in $current_category_id. There may be more than one heading for product.

     

    I have tried left join the customs to the current query and viceversa but I'm missing something.

     

    Someone please help me.

     

    Thank you!

    $products_query_raw = "select p.products_id, p.products_image, p.products_model, pd.products_name, p.products_status, p.products_quantity_order_min, p.products_price from  " . 
    TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION .  " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc where p.products_id = pd.products_id and pd.language_id = '$languages_id'
    and p.products_id = pc.products_id and pc.categories_id = '" . $current_category_id . "' 
    $sort_by ";

  10. This is oscommerce. See pic for details.

     

    I have this file to update multiple products at the same time. I need now to check multiples checkboxes in the right column and click the delete button and get these products deleted. The column is already created. I need the code to delete multiple rows at the same time.

     

    There is a funtion to delete individual products in oscommerce. Not sure if can be used.

     

    Please pm or post for this job. I need asap. Paypal payment only.

     

    delete_multiple_rows.jpg

  11. Thank you MadTechie.

    I still have a little problem with this. The first part produce only one value in the array, the last product viewed.

    On the second part, I don't get any results at all. This is what I did:

    //remove last item

    $tmp = array_pop($_SESSION['recently_viewed']);

    //create ; delimited string

    $tmp = implode(";",$_SESSION['recently_viewed']);

    //display string

    echo $tmp;

     

    I think may be the other part of the code has something to change but I don't know how do it.

     

    Thank you for your help.

     

    Greg

     

    new WhatsNewBoxHeading($info_box_contents, false, false);
    
        $counter = 0;
        $info_box_contents = array();
        $recent_products = split(';',$recently_viewed);
        $rows=0;
        $cols=0;
    $total=(MAX_ROWS*MAX_COLS); 
    
       foreach ($recent_products as $recent)
       {  
       if ((strlen($recent) >0) && ($counter < $total) && ($rows<MAX_ROWS))
    	   {
          $recent_info = tep_db_query("select  p.products_image from " . TABLE_PRODUCTS . " p where p.products_id = '" . $recent. "'");
          $recent_info_values = tep_db_fetch_array($recent_info);
          $counter++;
          if (strlen($counter) < 2)
    	  {
            $counter = '0' . $counter;
    	  }
          $info_box_contents[$rows][$cols] = array('align' => 'left',
                                'params' =>'valign="top" class="productListing-data"',                                 
    						'text'  => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $recent, 'NONSSL') . '">' .
    tep_image(DIR_WS_IMAGES . $recent_info_values['products_image'], 
    tep_get_products_name($recent)) . '</a><br>' . $counter . '. ' . tep_get_products_name($recent));
          $cols++;
          if ($cols >= MAX_COLS)
    	  {
            $cols = 0;
            $rows++;
    	  }
    	  }
       }    
    new tableBox($info_box_contents,true);

  12. OH my God!!!  ... here is it.

    if (!tep_session_is_registered('recently_viewed'))
    	{
    	tep_session_register('recently_viewed');
    	$recently_viewed = $HTTP_GET_VARS['products_id'] . ';';
    	}
    $check_not_duplicate = $HTTP_GET_VARS['products_id'];
    $temp_recent = $recently_viewed;
    if (!ereg($check_not_duplicate, $temp_recent ) )
     	$recently_viewed = $HTTP_GET_VARS['products_id'] . ';' . $recently_viewed ;
    ?>

  13. Just to add more info on this. Here are the functions to pull the manufacturer list and generate the category tree. My problem is that, from my point of view is that a new function is required to trim and pull the prefix in a selection and I don't know how to write that.

    Thanks

    function manufacturers_list(){
            global $manufacturer;
    
            $manufacturers_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m order by m.manufacturers_name ASC");
            $return_string = '<select name="manufacturer" onChange="this.form.submit();">';
            $return_string .= '<option value="' . 0 . '">' . TEXT_ALL_MANUFACTURERS . '</option>';
            while($manufacturers = tep_db_fetch_array($manufacturers_query)){
                    $return_string .= '<option value="' . $manufacturers['manufacturers_id'] . '"';
                    if($manufacturer && $manufacturers['manufacturers_id'] == $manufacturer) $return_string .= ' SELECTED';
                    $return_string .= '>' . $manufacturers['manufacturers_name'] . '</option>';
            }
            $return_string .= '</select>';
            return $return_string;
    }
    
    
    function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
        global $languages_id;
        if (!is_array($category_tree_array)) $category_tree_array = array();
        if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);
        if ($include_itself) {
          $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");
          $category = tep_db_fetch_array($category_query);
          $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
        }
        $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");
        while ($categories = tep_db_fetch_array($categories_query)) {
          if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);
          $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array);
        }
        return $category_tree_array;
      }

  14. I'm sorry to get you confused. I didn't write the code but I don't have any problem to show any part of the file. I tried to post the complete file but I got an error.

    BTW, If anyone can do this for me and charge for the code is fine, what I need is PAID or FREE help.

    That's why I come to this forum, to get help.

    Thanks

  15. The following code let me sort te results by categories and by manufacturer. I also need to create a result sorting by a prefix in the model number. The model_number is a field in the table products and a bunch of products have the prefix 2045-; a bunch of products the prefix 2075; others the prefix 2085 and many more. There is a total of 27 different prefix.

    Can anyone help me with this please.

    Thanks

     

         <table width="100%" cellspacing="3" cellpadding="3" border="0">
          <tr align="center">
        <td class="smalltext"><?php echo tep_draw_form('row_by_page', FILENAME_QUICK_UPDATES, '', 'get'); echo tep_draw_hidden_field( 'manufacturer', $manufacturer);
    echo tep_draw_hidden_field( 'cPath', $current_category_id);?></td>
     <td class="smallText"><?php echo TEXT_MAXI_ROW_BY_PAGE . '  ' . tep_draw_pull_down_menu('row_by_page', 
    $row_bypage_array, $row_by_page, 'onChange="this.form.submit();"'); ?></form></td>
       <?php echo tep_draw_form('categorie', FILENAME_QUICK_UPDATES, '', 'get'); echo tep_draw_hidden_field( 'row_by_page', $row_by_page); 
    echo tep_draw_hidden_field( 'manufacturer', $manufacturer); ?>
      <td class="smallText" align="center" valign="top"><?php echo DISPLAY_CATEGORIES . '  ' . tep_draw_pull_down_menu('cPath', tep_get_category_tree(), 
    $current_category_id, 'onChange="this.form.submit();"'); ?></td></form>
          <?php echo tep_draw_form('manufacturers', FILENAME_QUICK_UPDATES, '', 'get'); echo tep_draw_hidden_field( 'row_by_page', $row_by_page); 
    echo tep_draw_hidden_field( 'cPath', $current_category_id);?>
            <td class="smallText" align="center" valign="top"><?php echo DISPLAY_MANUFACTURERS . ' &nbsp' . manufacturers_list(); ?>
    </td></form>
          </tr>
        </table>

     

×
×
  • 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.