J'ai mis en place 2 manufacturers (manufacturer et manufacturers1 ) que j'utilise comme 2 critères (marque véhicule et accessoires).
J'ai donc placé ces 2 critères dans la colonne de gauche de mon site, afin que le client puisse facilement trier automatiquement via les 2 drop down menu, le problème c'est que ces 2 drop down menu sont indépendant entre eux.
En fait j'aimerais faire comme ceci, pouvoir sélectionner le critère 1 et 2 et cliquer sur un bouton "trier".
---- Marque véhicule ----
----- Accessoires -----
----- < trier > -----
Voici le code de mon manufacturer1
Code
<?php
$manufacturers1_query = tep_db_query("select distinct m.manufacturers1_id, m.manufacturers1_name from " . TABLE_MANUFACTURERS1 . " m, " . TABLE_PRODUCTS . " p where m.manufacturers1_id=p.manufacturers1_id order by manufacturers1_name");
if ($number_of_rows = tep_db_num_rows($manufacturers1_query)) {
?>
<!-- manufacturers1 //-->
<tr>
<td align="center">
<?php
echo tep_image_infobox('info_trie.gif');
$info_box_contents = array();
$info_box_contents[] = array('text' => '');
new infoBoxHeading($info_box_contents, false, false);
if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
// Display a list
while ($manufacturers1 = tep_db_fetch_array($manufacturers1_query)) {
$manufacturers_name = ((strlen($manufacturers1['manufacturers1_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers1_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers1['manufacturers1_name']);
if (isset($HTTP_GET_VARS['manufacturers1_id']) && ($HTTP_GET_VARS['manufacturers1_id'] == $manufacturers1['manufacturers1_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>';
}
$info_box_contents = array();
} else {
// Display a drop-down
$manufacturers1_array = array();
if (MAX_MANUFACTURERS_LIST < 2) {
$manufacturers1_array[] = array('align' => 'center', 'id' => '', 'text' => '---- Marque ----');
}
while ($manufacturers1 = tep_db_fetch_array($manufacturers1_query)) {
$manufacturers1_name = ((strlen($manufacturers1['manufacturers1_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers1['manufacturers1_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers1['manufacturers1_name']);
$manufacturers1_array[] = array('id' => $manufacturers1['manufacturers1_id'],
'text' => $manufacturers1_name);
}
$info_box_contents[] = array( 'align' => 'center',
'form' => tep_draw_form('manufacturers1', tep_href_link('index_search.php', '', 'NONSSL', false), 'get'),
'text' => tep_draw_pull_down_menu('manufacturers1_id', $manufacturers1_array, (isset($HTTP_GET_VARS['manufacturers1_id']) ? $HTTP_GET_VARS['manufacturers1_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 80%"') . tep_hide_session_id());
}
new infoBox ($info_box_contents);
?>
</td>
</tr>
<!-- manufacturers_eof //-->
<?php
}
?>
$manufacturers1_query = tep_db_query("select distinct m.manufacturers1_id, m.manufacturers1_name from " . TABLE_MANUFACTURERS1 . " m, " . TABLE_PRODUCTS . " p where m.manufacturers1_id=p.manufacturers1_id order by manufacturers1_name");
if ($number_of_rows = tep_db_num_rows($manufacturers1_query)) {
?>
<!-- manufacturers1 //-->
<tr>
<td align="center">
<?php
echo tep_image_infobox('info_trie.gif');
$info_box_contents = array();
$info_box_contents[] = array('text' => '');
new infoBoxHeading($info_box_contents, false, false);
if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
// Display a list
while ($manufacturers1 = tep_db_fetch_array($manufacturers1_query)) {
$manufacturers_name = ((strlen($manufacturers1['manufacturers1_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers1_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers1['manufacturers1_name']);
if (isset($HTTP_GET_VARS['manufacturers1_id']) && ($HTTP_GET_VARS['manufacturers1_id'] == $manufacturers1['manufacturers1_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>';
}
$info_box_contents = array();
} else {
// Display a drop-down
$manufacturers1_array = array();
if (MAX_MANUFACTURERS_LIST < 2) {
$manufacturers1_array[] = array('align' => 'center', 'id' => '', 'text' => '---- Marque ----');
}
while ($manufacturers1 = tep_db_fetch_array($manufacturers1_query)) {
$manufacturers1_name = ((strlen($manufacturers1['manufacturers1_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers1['manufacturers1_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers1['manufacturers1_name']);
$manufacturers1_array[] = array('id' => $manufacturers1['manufacturers1_id'],
'text' => $manufacturers1_name);
}
$info_box_contents[] = array( 'align' => 'center',
'form' => tep_draw_form('manufacturers1', tep_href_link('index_search.php', '', 'NONSSL', false), 'get'),
'text' => tep_draw_pull_down_menu('manufacturers1_id', $manufacturers1_array, (isset($HTTP_GET_VARS['manufacturers1_id']) ? $HTTP_GET_VARS['manufacturers1_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 80%"') . tep_hide_session_id());
}
new infoBox ($info_box_contents);
?>
</td>
</tr>
<!-- manufacturers_eof //-->
<?php
}
?>
et celui de mon manufacturer:
Code
<?php
$manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS . " p where m.manufacturers_id=p.manufacturers_id order by manufacturers_name");;
if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {
?>
<!-- manufacturers //-->
<tr>
<td align="center">
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => '');
new infoBoxHeading($info_box_contents, false, false);
if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
// Display a list
$manufacturers_list = '';
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
if (isset($HTTP_GET_VARS['manufacturers_id']) && ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers['manufacturers_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>';
$manufacturers_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">' . $manufacturers_name . '</a><br>';
}
$manufacturers_list = substr($manufacturers_list, 0, -4);
$info_box_contents = array();
$info_box_contents[] = array('text' => $manufacturers_list);
} else {
// Display a drop-down
$manufacturers_array = array();
if (MAX_MANUFACTURERS_LIST < 2) {
$manufacturers_array[] = array('id' => '', 'text' => '---- Propulseur ----');
}
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
$manufacturers_array[] = array('align' => 'center',
'id' => $manufacturers['manufacturers_id'],
'text' => $manufacturers_name);
}
$info_box_contents = array();
$info_box_contents[] = array( 'align' => 'center',
'form' => tep_draw_form('manufacturers', tep_href_link('index_search.php', '', 'NONSSL', false), 'get'),
'text' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 80%"') . tep_hide_session_id());
}
new infoBox ($info_box_contents);
?>
</td>
</tr>
<!-- manufacturers_eof //-->
<?php
}
?>
$manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS . " p where m.manufacturers_id=p.manufacturers_id order by manufacturers_name");;
if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {
?>
<!-- manufacturers //-->
<tr>
<td align="center">
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => '');
new infoBoxHeading($info_box_contents, false, false);
if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
// Display a list
$manufacturers_list = '';
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
if (isset($HTTP_GET_VARS['manufacturers_id']) && ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers['manufacturers_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>';
$manufacturers_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">' . $manufacturers_name . '</a><br>';
}
$manufacturers_list = substr($manufacturers_list, 0, -4);
$info_box_contents = array();
$info_box_contents[] = array('text' => $manufacturers_list);
} else {
// Display a drop-down
$manufacturers_array = array();
if (MAX_MANUFACTURERS_LIST < 2) {
$manufacturers_array[] = array('id' => '', 'text' => '---- Propulseur ----');
}
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
$manufacturers_array[] = array('align' => 'center',
'id' => $manufacturers['manufacturers_id'],
'text' => $manufacturers_name);
}
$info_box_contents = array();
$info_box_contents[] = array( 'align' => 'center',
'form' => tep_draw_form('manufacturers', tep_href_link('index_search.php', '', 'NONSSL', false), 'get'),
'text' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 80%"') . tep_hide_session_id());
}
new infoBox ($info_box_contents);
?>
</td>
</tr>
<!-- manufacturers_eof //-->
<?php
}
?>
Il faut donc fusionner les 2 dans la même instruction, j'ai donc commencé par la préparation du query:
Voici donc le query d'origine pour le manufacturer1:
Code
$manufacturers1_query = tep_db_query("select distinct m.manufacturers1_id, m.manufacturers1_name from " . TABLE_MANUFACTURERS1 . " m, " . TABLE_PRODUCTS . " p where m.manufacturers1_id=p.manufacturers1_id order by manufacturers1_name");
et voici les 2 (manufacturers et manufacturers1), est ce correcte ?:
Code
$manufacturers1_query = tep_db_query("select distinct m.manufacturers1_id, m.manufacturers1_name from " . TABLE_PRODUCTS . " p, " . TABLE_MANUFACTURERS . " m, " . TABLE_MANUFACTURERS1 . " m1, p where m.manufacturers1_id=p.manufacturers1_id order by manufacturers1_name");
if ($number_of_rows = tep_db_num_rows($manufacturers1_query)) {
if ($number_of_rows = tep_db_num_rows($manufacturers1_query)) {
Malheureusement çà ne fonctionne pas, j'ai ce message d'erreur (SQL):
Code
1066 - Not unique table/alias: 'p'
select distinct m.manufacturers1_id, m.manufacturers1_name from products p, manufacturers m, manufacturers1 m1, p where m.manufacturers1_id=p.manufacturers1_id order by manufacturers1_name
[TEP STOP]
select distinct m.manufacturers1_id, m.manufacturers1_name from products p, manufacturers m, manufacturers1 m1, p where m.manufacturers1_id=p.manufacturers1_id order by manufacturers1_name
[TEP STOP]