vanvoquan Posted November 14, 2010 Share Posted November 14, 2010 Hi everyone. I have this 3 table: table: Products_options products_options_id: 1, 2, 3 products_options_name: color, size, model table: products_attribues Products_attributes_id: 32, 33, 34, 35 products_id: 68, 68, 68, 68 options_values_id: 23, 25, 5, 7 table: Products_options_values products_options_values_id: 5, 7, 23, 25 products_options_values_name: 5, 7, black, chestnut I want to echo only the colors of this product which is black and chestnut. I use the query below but It give me everything, include the color, the size, the model. I only want to echo the colors of the product. Below is the query: <?php $products_options_query_cuong = tep_db_query("select pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov left join " . TABLE_PRODUCTS_ATTRIBUTES . " pa on (pa.options_values_id = pov.products_options_values_id and pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'), " . TABLE_PRODUCTS_OPTIONS . " po where po.products_options_id = 1 "); while($products_options_cuong = tep_db_fetch_array($products_options_query_cuong)) { ?> Can anyone show me why isn't give me only the colors. Any helps will be greatly appriciate. Vanvoquan Quote Link to comment https://forums.phpfreaks.com/topic/218622-what-wrong-with-this-query/ Share on other sites More sharing options...
vanvoquan Posted November 14, 2010 Author Share Posted November 14, 2010 I able to narrow down the query. But it's still give the the colors and the size. I have limited it to echo only the color with this one " po.products_options_id = 1 " , but it no help at all. This is the new query : <?php $products_options_query_cuong = tep_db_query("select pov.products_options_values_name from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS . " po where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_values_id = pov.products_options_values_id and po.products_options_id = 1 and pov.language_id = '" . (int)$languages_id . "'"); while($products_options_cuong = tep_db_fetch_array($products_options_query_cuong)) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/218622-what-wrong-with-this-query/#findComment-1134011 Share on other sites More sharing options...
joel24 Posted November 14, 2010 Share Posted November 14, 2010 run this and post what it prints exit("select pov.products_options_values_name from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS . " po where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_values_id = pov.products_options_values_id and po.products_options_id = 1 and pov.language_id = '" . (int)$languages_id . "'"); Quote Link to comment https://forums.phpfreaks.com/topic/218622-what-wrong-with-this-query/#findComment-1134162 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.