Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Im trying to create a drop down menu style search similar to the way the manufacturer sort that comes with osc works. So far after hack and slashing my way through the manufacturer.php ive come up with this code

<?php
/*
 $Id: manufacturers.php,v 1.19 2003/06/09 22:17:13 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $extrafields_query = tep_db_query("select products_extra_fields_id, products_extra_fields_name from " . products_extra_fields . " order by products_extra_fields_name");
 if ($number_of_rows = tep_db_num_rows($extrafields_query)) {
?>
<!-- extra fields //-->
         <tr>
           <td>
<?php
   $info_box_contents = array();
   $info_box_contents[] = array('text' => 'Make/Model' );

   new infoBoxHeading($info_box_contents, false, false);

   if ($number_of_rows <= 1 ) {
// Display a list
     $extrafields_list = '';
     while ($extrafields = tep_db_fetch_array($extrafields_query)) {
       $extrafields_name = ((strlen($extrafields['products_extra_fields_name']) > 32) ? substr($extrafields['products_extra_fields_name'], 0, 32) . '..' : $extrafields['products_extra_fields_name']);
       if (isset($HTTP_GET_VARS['products_extra_fields_id']) && ($HTTP_GET_VARS['products_extra_fields_id'] == $extrafields['products_extra_fields_id'])) $extrafields_name = '<b>' . $extrafields_name .'</b>';
       $extrafields_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'products_extra_fields_id=' . $extrafields['products_extra_fields_id']) . '">' . $extrafields_name . '</a><br>';
     }

     $extrafields_list = substr($extrafields_list, 0, -4);

     $info_box_contents = array();
     $info_box_contents[] = array('text' => $extrafields_list);
   } else {
// Display a drop-down
     $extrafields_array = array();
     if (MAX_MANUFACTURERS_LIST < 2) {
       $extrafields_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);
     }

     while ($extrafields = tep_db_fetch_array($extrafields_query)) {
       $extrafields_name = ((strlen($extrafields['products_extra_fields_name']) > 32) ? substr($extrafields['products_extra_fields_name'], 0, 32) . '..' : $extrafields['products_extra_fields_name']);
       $extrafields_array[] = array('id' => $extrafields['products_extra_fields_id'],
                                      'text' => $extrafields_name);
     }

     $info_box_contents = array();
     $info_box_contents[] = array('form' => tep_draw_form('extrafields', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'),
                                  'text' => tep_draw_pull_down_menu('products_extra_fields_id', $extra_fields_array, (isset($HTTP_GET_VARS['products_extra_fields_id']) ? $HTTP_GET_VARS['products_extra_fields_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"') . tep_hide_session_id());
   }

   new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- extra_fields_eof //-->
<?php
 }
?>

 

Problem being its not populating the drop down menu, after thoroughly checking it over I cant find my mistake so I thought id give you guys a shot at it. Im 99.9% sure its calling the table fine from sql so the problem is elsewhere. Any help would be appreciated TIA!

Posted

I dont intend on ever using this outside of a dropdown so ive ditched the if statement for the table to streamline it a little more, still no luck. :huh:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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