hogash Posted February 17, 2008 Posted February 17, 2008 Hello, I have this script that displays subcategories. What i need is to display them in 2 or more columns. Please help!! if ($cPath) { $subcategories_string = ''; $new_path = ''; $id = split('_', $cPath); reset($id); while (list($key, $value) = each($id)) { unset($prev_id); unset($first_id); $subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id order by sort_order, cd.categories_name"); $subcategory_check = tep_db_num_rows($subcategories_query); if ($subcategory_check > 0) { $new_path .= $value; while ($row = tep_db_fetch_array($subcategories_query)) { $fooa[$row['categories_id']] = array( 'name' => $row['categories_name'], 'parent' => $row['parent_id'], 'level' => $key+1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => true ); if (isset($prev_id)) { $fooa[$prev_id]['next_id'] = $row['categories_id']; } $prev_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $fooa[$last_id]['next_id'] = $fooa[$value]['next_id']; $fooa[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } function show_subcategories($counter) { global $fooa, $subcategories_string, $id, $HTTP_GET_VARS; $cPath_new = 'cPath=' . $fooa[$counter]['path']; $subcategories_string .= '<a href="'; $ph = $_GET['ph']; if($fooa[$counter]['path'] == $_GET['cPath']) { $subcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new.'&ph='.$ph) . '" id="submen_sel">'; } else { $subcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new.'&ph='.$ph) . '">'; } // display category name $subcategories_string .= $fooa[$counter]['name']; $subcategories_string .= '</a><br>'; if ($fooa[$counter]['next_id']) { show_subcategories($fooa[$counter]['next_id']); }else{ $subcategories_string .= ''; } } if ($id[0] != ''){ show_subcategories($id[0]); echo $subcategories_string; }
web-project Posted February 17, 2008 Posted February 17, 2008 search in contributions & you will find ready made code. Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here! 8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself. Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues. Any issues with oscommerce, I am here to help you.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.