Jump to content

Recommended Posts

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>

 

Link to comment
https://forums.phpfreaks.com/topic/115592-need-help-in-sorting-a-result/
Share on other sites

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

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;
  }

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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