Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

All products with select


Guest

Recommended Posts

my problem is that I doubled the name

 

<?php

$products_query = tep_db_query("select products_name, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " order by products_name");

if ($number_of_rows = tep_db_num_rows($products_query)) {

$products_array = array();

 

while ($products = tep_db_fetch_array($products_query)) {

$products_name = ((strlen($products['products_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($products['products_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $products['products_name']);

$products_array[] = array('id' => $products['products_id'],

'text' => $products_name);

}

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('products', tep_href_link(FILENAME_PRODUCT_INFO, '', 'NONSSL', false), 'get'),

'text' => tep_draw_pull_down_menu('products_id', $products_array, (isset($HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"') . tep_hide_session_id());

new infoBox1($info_box_contents);

}

?>

Link to comment
Share on other sites

Solutions

 

<?php

$products_query = tep_db_query("SELECT products_id, products_name FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE language_id = '" . $languages_id . "' ORDER BY products_name");

if ($number_of_rows = tep_db_num_rows($products_query)) {

$products_array = array();

 

while ($products = tep_db_fetch_array($products_query)) {

$products_name = ((strlen($products['products_name']) > '50') ? substr($products['products_name'], 0, '50') . '..' : $products['products_name']);

$products_array[] = array('id' => $products['products_id'],

'text' => $products_name);

}

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('products', tep_href_link(FILENAME_PRODUCT_INFO, '', 'NONSSL', false), 'get'),

'text' => tep_draw_pull_down_menu('products_id', $products_array, (isset($HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"') . tep_hide_session_id());

new infoBox1($info_box_contents);

}

?>

 

and include status ?

 

any idea

Link to comment
Share on other sites

Solution

 

<?php

$products_query = tep_db_query("select distinct p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name ");

if ($number_of_rows = tep_db_num_rows($products_query)) {

$products_array = array();

if ($products_name < 2) {

$products_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);

}

 

while ($products = tep_db_fetch_array($products_query)) {

$products_name = ((strlen($products['products_name']) > '50') ? substr($products['products_name'], 0, '50') . '..' : $products['products_name']);

$products_array[] = array('id' => $products['products_id'],

'text' => $products_name);

}

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('products', tep_href_link(FILENAME_PRODUCT_INFO, '', 'NONSSL', false), 'get'),

'text' => tep_draw_pull_down_menu('products_id', $products_array, (isset($HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : ''), 'onChange="this.form.submit();" size="' . '1' . '" style="width: 100%"') . tep_hide_session_id());

new infoBox($info_box_contents);

}

?>

Edited by davchi2005
Link to comment
Share on other sites

Join the conversation

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

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