Susan Carembeu 0 Posted September 22, 2005 Hi, Claudio and folks! I need your help! This contribution is pretty good, i love it but... If i have subcategories and parent categories it shows me just the sub categories. F. ex.: Mainboards (parent) - AMD (sub 1) - Asus (sub 2) - MSI (sub 2) - Intel (sub 1) - Asus (sub 2) - Abit (sub 2) It shows me: AMD (the sub1 category) - Asus (the manufacturer) I tried to achieve something like this: Mainboards - AMD - Asus **table product list Mainboards - AMD - MSI **table product list etc. but I could not... :( Would you be so good and help me out? Please... Susan Share this post Link to post Share on other sites
Susan Carembeu 0 Posted September 23, 2005 Hi! OK. Cuz nobody answered til now I try to explain my problem again... Here is the code of "report-txt.php" file: <html> <head> <style type="text/css"> table.report { border: 1px solid Black; page-break-after: auto; page: auto; border-collapse: collapse; font-family: Arial, Verdana, sans-serif; font-size: 12px; padding: 6px; } h2.report { font-family: Arial, Verdana, sans-serif; font-size: 16px; } td.price { font-family: Arial, Verdana, sans-serif; font-size: 14px; text-align: right; border: 1px solid; padding: 3px; } td.report { border: 1px solid; padding: 3px; } </style> </head> <body> <?php // $records = tep_db_query("SELECT * FROM products_to_categories ORDER BY categories_id"); $qry = "select distinct c.categories_name, pd.products_name, pd.products_description, p.products_price, p.products_image, m.manufacturers_name" . " from " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES_DESCRIPTION . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m" . " where p.products_id = pd.products_id and p.manufacturers_id = m.manufacturers_id and p.products_id = pc.products_id and pc.categories_id = c.categories_id AND c.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "'" . " order by trim(c.categories_name), m.manufacturers_name, trim(pd.products_name) asc"; $records = tep_db_query($qry); $num_records = tep_db_num_rows($records); ?> <table width=600> <TR> <td align="center"> <p> </p> <p> </p> <h2><b><i>Price List: </i></b></h2> <p><? echo $num_records; ?> products <? $i = 0; $table = mysql_fetch_array($records); while ($table) { $category1 = $table['categories_name']; $manufacturer1 = $table['manufacturers_name']; ?> <h2 class="report" align="left"> <? echo $category1 . ": " . $manufacturer1; ?> </h2> <table class="report"> <TR> <TH width=500 align="left" class="report">Product</TH> <th width=80 align="left" class="report">Price</th> </TR> <? do { $category = $table['categories_name']; $manufacturer = $table['manufacturers_name']; $product = $table['products_name']; $price = $table['products_price']; $description = $table['products_description']; if ($category != $category1 || $manufacturer != $manufacturer1) { ?> </table> <? break; } if (!($i%2)) {$color = "BGCOLOR = #FFFF99";} else { $color = "BGCOLOR = #FFFFFF";} ?> <tr> <td class="report"> <? echo $product;?> </td> <td class="price"> <? echo number_format ($price,2,',','.');?> </td> </tr> <? $i++; } while ($table = mysql_fetch_array($records)); } ?> </td> </tr> </table> </body> </html> If i use this code on a shop where are just main categories and products in them its ok. But when Ive got parent cat. - sub categories - products the $category1 returns the sub category-s name. And I need to change this code to show the path. For example: Motherboards (this is the top category) Intel (this is under motherb.) AMD (this is under motherb.) ASUS (this is under motherb./Intel) Abit (this is under motherb./Intel) ASUS(this is under motherb./AMD) MSI(this is under motherb./Intel) So when i run the php file Ive got for the category1 = Intel (then products) and AMD (then products) and if I have lot of categories with subcateg. its quite confusing wher is what. I need something like: Motherboards - AMD - ASUS //* product list of ASUS motherboards, with AMD socket Motherboards - AMD - Abit //* product list of Abit motherboards, with AMD socket Motherboards - Intel - ASUS //* product list of ASUS motherboards, with Intel socket etc. Please help me! Share this post Link to post Share on other sites
gty 0 Posted September 23, 2005 I found a nice contribution it called Box_categories_pro_V1.1 just do a search for it. Share this post Link to post Share on other sites
Susan Carembeu 0 Posted September 24, 2005 I found a nice contribution it called Box_categories_pro_V1.1 just do a search for it. <{POST_SNAPBACK}> Thank you, Hmmm... Im not sure if i need that. Im trying to make a price list, or product list. The report-txt.php file is pretty good. Its almost perfect for me, just i need to change it a little bit - to show the parent categories. Share this post Link to post Share on other sites
Johnson 0 Posted September 24, 2005 You need to add parent_id and TABLE_CATEGORIES to your query, then use something like this: <? $i = 0; $table = mysql_fetch_array($records); while ($table) { $parent_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c on cd. categories_id = c.categories_id where c.categories_id = '" . $table['parent_id'] . "'"); $parent_result = tep_db_fetch_array($parent_query); $parent = $parent_result['categories_name']; $category1 = $table['categories_name']; $manufacturer1 = $table['manufacturers_name']; ?> You can echo the result with $parent :D Matti Matti Ressler We were all once expert at...... nothing _____ Share this post Link to post Share on other sites
Susan Carembeu 0 Posted September 24, 2005 You need to add parent_id and TABLE_CATEGORIES to your query, then use something like this: <? $i = 0; ? ? ? ? ? ? ? $table = mysql_fetch_array($records); while ($table) { ?$parent_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c on cd. categories_id = c.categories_id where c.categories_id = '" ?. $table['parent_id'] . "'"); ?$parent_result = tep_db_fetch_array($parent_query); ?$parent = $parent_result['categories_name']; ? ?$category1 = $table['categories_name']; ?$manufacturer1 = $table['manufacturers_name']; ? ?> You can echo the result with $parent :D Matti <{POST_SNAPBACK}> Thanx! Ive almost got it! I was looking for some codes like yours and Ive found a price list contribution - heres the code: <?php define('TITLE_PRICE', 'Title'); define('SHOW_QUANTITY',false); // true - show, false - hide quantity define('SHOW_MARKED_OUT_STOCK',false); // show marked out of stock (true - show, false - hide) define('TAX_INCREASE', 0); // 0 - No increase, 1 - Add 1%, 5 - Add 5%, Any number - add number% define('SHOW_MODEL',true); // true - show model, false - hide model require('includes/application_top.php'); // the following cPath references come from application_top.php $category_depth = 'top'; if (isset($cPath) && tep_not_null($cPath)) { $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); $cateqories_products = tep_db_fetch_array($categories_products_query); if ($cateqories_products['total'] > 0) { $category_depth = 'products'; // display products } else { $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'"); $category_parent = tep_db_fetch_array($category_parent_query); if ($category_parent['total'] > 0) { $category_depth = 'nested'; // navigate through the categories } else { $category_depth = 'products'; // category has no products, but display the 'no products' message } } } ?> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?> - Cenn?k <?php echo date("Y"); ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td> <? // group have products? function check_products($id_group){ $products_price_query = tep_db_query("select products_to_categories.products_id FROM products_to_categories where products_to_categories.categories_id = ".$id_group." LIMIT 0,1"); if($products_price = tep_db_fetch_array($products_price_query)){ return true; } return false; } // list products determined group function get_products($id_group){ global $currencies; $query = ""; if(!SHOW_MARKED_OUT_STOCK){ $query = " and products.products_status = 1"; } $products_price_query = tep_db_query("select products_description.products_name, products.products_quantity, products.products_price, products.products_model, products_to_categories.products_id, products_to_categories.categories_id FROM products, products_description, products_to_categories where products.products_id = products_description.products_id and products.products_quantity <> 0".$query." and products.products_id = products_to_categories.products_id and products_to_categories.categories_id = ".$id_group); $x=0; while ($products_price = tep_db_fetch_array($products_price_query)){ $cell = tep_get_products_special_price($products_price['products_id']); if($cell == 0) $cell = $products_price['products_price']; if($x==1) { $col = "#F8F8F9"; $x = 0; }else{ $col = "#FFFFFF"; $x++; } $quantity = ""; $model = ""; if(SHOW_QUANTITY) $quantity = "<td width=\"100\" align=\"right\" class=\"productListing-data\">(".$products_price['products_quantity'].")</td>"; if(SHOW_MODEL) $model = "<td width=\"100\" align=\"right\" class=\"productListing-data\">[".$products_price['products_model']."]</td>"; print "<tr bgcolor=\"".$col."\">".$model."<td width=\"1000\" class=\"productListing-data\"> <a href=\"" . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $products_price['products_id']) . "\">".$products_price['products_name']."</a></td><td width=\"150\" align=\"right\" class=\"productListing-data\">".$currencies->display_price($cell,TAX_INCREASE)."</td></tr>"; } } // get all groups function get_group($id_parent,$position){ $groups_price_query = tep_db_query("select categories.categories_id, categories_description.categories_name from categories, categories_description where categories.categories_id = categories_description.categories_id and categories.parent_id = ".$id_parent." order by categories.sort_order"); while ($groups_price = tep_db_fetch_array($groups_price_query)){ $str = ""; for($i = 0; $i < $position; $i++){ $str = $str . " "; } $class = "productListing-heading"; if($position == 0) { $class = "headerNavigation"; print "<tr><td colspan=\"4\" width=\"1000\" class=\"productListing-data\"> </td></tr>"; } if(check_products($groups_price['categories_id']) || $position == 0){ print "<tr><td colspan=\"4\" width=\"1000\" class=\"".$class."\"><strong><font color=\"#000000\">".$str.$groups_price['categories_name']."</font></strong></td></tr>"; get_products($groups_price['categories_id']); } get_group($groups_price['categories_id'],$position+1); } } ?> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <? get_group(0,0); ?> </table> </td> </tr> </table> I was searching for smthg like this! Just 2 things to change and im the most happiest person at the osc forum! :D So what should I change here to list the products based not on their ID number but on their letters? (im not native so forgive my english pls!) But I hope you will know what I mean! Snd. thing is to print the products description! I learned that its in the: $products_price_query = tep_db_query("select products_description.products_name, products.products_quantity, products.products_price, products.products_ etc..) And that i have to print the products_description. But in this case its declared in a way which I do not understand... Like products_description.products_name - what? Everywere it was like p.products_name, pd.products_description and so on, but here it is pretty complicated for me... Oh, yes - thank you Mr. Johnson! Share this post Link to post Share on other sites
Johnson 0 Posted September 24, 2005 (edited) You already have the products description in the first code you posted - to display it: <?php echo $description; ?> :D Matti Edited September 24, 2005 by Johnson Matti Ressler We were all once expert at...... nothing _____ Share this post Link to post Share on other sites
Johnson 0 Posted September 24, 2005 (edited) This works for me :D <?php /* ?$Id: report.php Exp $ ?osCommerce, Open Source E-Commerce Solutions ?http://www.oscommerce.com ?Copyright (c) 2003 osCommerce ? ?Suomedia - Dynamic Content Management ?http://suomedia.com ? ?Copyright (c) 2005 Suomedia ? ?Released under the GNU General Public License */ ?require('includes/application_top.php'); ?> <html> <head> <style type="text/css"> table.report { border: 1px solid Black; page-break-after: auto; page: auto; border-collapse: collapse; font-family: Arial, Verdana, sans-serif; font-size: 12px; padding: 6px; } h2.report { font-family: Arial, Verdana, sans-serif; font-size: 16px; } td.price { font-family: Arial, Verdana, sans-serif; font-size: 14px; text-align: right; border: 1px solid; padding: 3px; } td.report { border: 1px solid; padding: 3px; } </style> </head> <body> <?php $qry = "select distinct c.categories_name, a.parent_id, pd.products_name, pd.products_description, p.products_price, p.products_image, m.manufacturers_name" . ? ? ?" from " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES_DESCRIPTION . " c, " . TABLE_CATEGORIES . " a, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m" . ? ? ?" where p.products_id = pd.products_id and p.manufacturers_id = m.manufacturers_id and p.products_id = pc.products_id and pc.categories_id = c.categories_id AND c.categories_id = a.categories_id AND c.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "'" . ? ? ?" order by trim(c.categories_name), m.manufacturers_name, trim(pd.products_name) asc"; ? $records = tep_db_query($qry); $num_records = tep_db_num_rows($records); ? ?> <table width=600> ?<TR> ?<td align="center"> ? <p> </p> ? <p> </p> ? <h2><b><i>Price List: </i></b></h2> ? <p><? ? echo $num_records; ?> products <? $i = 0; ? ? ? ? ? ? ? $table = mysql_fetch_array($records); while ($table) { ?$parent_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c on cd. categories_id = c.categories_id where c.categories_id = '" ?. $table['parent_id'] . "'"); ?$parent_result = tep_db_fetch_array($parent_query); ?$parent = $parent_result['categories_name']; ? ?$category1 = $table['categories_name']; ?$manufacturer1 = $table['manufacturers_name']; ? ?> ? <h2 class="report" align="left"> <? echo $parent . ": " . $category1 . ": " . $manufacturer1; ?> </h2> ? <table class="report"> ? <TR> ? ?<TH width=500 align="left" class="report">Product</TH> ? ?<th width=80 align="left" class="report">Price</th> ? </TR> <? ?do { ? $category = $table['categories_name']; ? $manufacturer = $table['manufacturers_name']; ? $product = $table['products_name']; ? $price = $table['products_price']; ? $description = $table['products_description']; ? if ($category != $category1 || $manufacturer != $manufacturer1) { ? ??> </table> <? ? ? ? break; ? } ? ? if (!($i%2)) {$color = "BGCOLOR = #FFFF99";} ? else { $color = "BGCOLOR = #FFFFFF";} ? ? ? ? ? ? ?> ?<tr> ? ? <td class="report"> ? ? ?<? echo '<b>' . $product . '</b><br><br>' . $description;?> ? ? </td> ? ? <td class="price"> ? ? ?<? echo number_format ($price,2,',','.');?> ? ? </td> ? ?</tr> ? <? ? $i++; ?} while ($table = mysql_fetch_array($records)); } ?> ?</td> ?</tr> </table> </body> </html> Edited September 24, 2005 by Johnson Matti Ressler We were all once expert at...... nothing _____ Share this post Link to post Share on other sites
Susan Carembeu 0 Posted September 24, 2005 THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! This was exactly what I was trying to make! :thumbsup: :thumbsup: :thumbsup: Share this post Link to post Share on other sites