Jump to content
Sign in to follow this  
davchi2005

All products with select

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

}

?>

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×