function displayCategories($categories, $prefix = "") { foreach ($categories as $category) { printf("%s%s [%s]\n", $prefix, $category->name, $category->id); if (isset($category->children)) { displayCategories($category->children, "{$prefix}{$category->name} > "); } } }
<header> <h1>Online-Catalog</h1> </header> <div> <form method="get"> Select Category: <select name="categoryId"> <!-- this data should be coming from the database --> <option value="0">None</option> <?php echo displayCategories(); ?> </select> Title: <input type="text" name="title" /><!--value="<?php echo $_GET['title']; ?> "--> Rating: <select name="rating"> <option value="11">None</option> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option>
//Get all the categories $categoriesNode = $mappedNode->item(0)->getElementsByTagName('Category'); if ($categoriesNode->length > 0) { //if there are some categories then display them echo '<P><B>MAPPED</B>'; displayCategories($categoriesNode); } } //DISPLAY UNMAPPED CATEGORIES - if any if ($unmappedNode->length > 0 && $unmappedNode->item(0)->childNodes->length > 0) { //Get all the categories $categoriesNode = $unmappedNode->item(0)->getElementsByTagName('Category'); if (count($categoriesNode) > 0) { //if there are some categories then display them echo '<P><B>UNMAPPED</B>'; displayCategories($categoriesNode); } } //DISPLAY SITE-WIDE CSs if ($siteWideNode->length > 0 && $siteWideNode->item(0)->childNodes->length > 0) { $csNodes = $siteWideNode->item(0)->getElementsByTagName('CharacteristicsSet'); if ($csNodes->length > 0) { //if there are some Site-Wide CSs echo '<P><B>SITE-WIDE CHARACTERISTICS SETS</B>'; //go throught each one foreach ($csNodes as $cs) { //get its details $csIDNode = $cs->getElementsByTagName('AttributeSetID'); $versionNode = $cs->getElementsByTagName('AttributeSetVersion'); $nameNode = $cs->getElementsByTagName('Name'); //output details
<select disabled="disabled" class="metadata_selectbox" id="featuretype_inspire_category_id" name="featuretype_inspire_category_id" size="2" multiple="multiple"> <?php $sql = "SELECT inspire_category_id AS id, inspire_category_code_en AS name FROM inspire_category"; echo displayCategories($sql); ?> </select> <img id="resetInspireCats" title="<?php echo _mb("Reset selection"); ?> " src="../img/cross.png" style="cursor:pointer;"/> </p> <p> <label for="featuretype_custom_category_id" class="label_classification"><?php echo _mb("Custom Category"); ?> :</label> <span class="metadata_span"></span> <select disabled="disabled" class="metadata_selectbox" id="featuretype_custom_category_id" name="featuretype_custom_category_id" size="2" multiple="multiple"> <?php $sql = "SELECT custom_category_id AS id, custom_category_code_en AS name FROM custom_category"; echo displayCategories($sql); ?> </select> <img id="resetCustomCats" title="<?php echo _mb("Reset selection"); ?> " src="../img/cross.png" style="cursor:pointer;"/> </p> </fieldset> </div>
<input type="hidden" name="ad_views" readonly="readonly"> <input type="hidden" name="date_registered" readonly="readonly"> <input type="hidden" name="date_posted" readonly="readonly"> <label for="title">Title</label> <input type="text" name="title" id="title" placeholder="Title of your advert" required="required"/> <label for="price">Price</label> <input type="tel" name="price" id="price" placeholder="The price of the item" required="required"/> <select for="id_category" name="id_category" required="required"> <option>Category</option> <?php echo displayCategories($_SESSION["id_category"]); ?> </select> <!-- <label>Ad Type</label> <select name="ad_type"> <option value="S">For Sale</option> <option value="W">Wanted</option> </select> --> <label for="description">Description</label> <textarea for="description" name="description" placeholder="A description will help to make a sale" required="required"></textarea> <label>County</label>
<li><a href="homepage.php">Home</a></li> <li><?php echo $viewProfile; ?> </li> <li><a href="place-ad.php">Place An Ad</a></li> </ul> </nav> <div class="search"> <h3>Search</h3> <form action="homepage.php" method="get"> <select name="category"> <option value="">Select Category <?php echo displayCategories($cat); ?> </option> </select> <input type="search" name="q" placeholder="Search..." value="<?php echo $q; ?> "> <button type="submit">Search</button> </form> </div> <h2>Recent Adverts</h2> <main>
<input type='submit' value='Change Category'> </form> <div class='thirdFilter'> <form method='get' action='index.php?'> <input type='hidden' name='live' value='live'> <input type='submit' value='LIVE'> </form> </div> </div> <div class='homeThread'> _E; if ($whatToDisplay == 0) { showAllThreadsUse(); } elseif ($whatToDisplay == 1) { displayCategories($get); } elseif ($whatToDisplay == 2) { displayByViews(); } elseif ($whatToDisplay == 3) { displayByRatings(); } elseif ($whatToDisplay == 4) { removeOldLiveThreads(); displayAllLiveThreads(); } elseif ($whatToDisplay == 5) { displayViewsAndCategory($category); } elseif ($whatToDisplay == 6) { displayRateAndCategory($category); } elseif ($whatToDisplay == 7) { displaySearch($useTitle); } echo <<<_F
/** * @param $menuid_string is set from $categories['menuid_string'] * it is used later by the sitemap addon of this script */ $menuid_string = $categories['menuid_string']; // Print the javascript for the suckertree var menuids echo $categories['menuid_js'] . PHP_EOL; unset($categories['menuid_string'], $categories['menuid_js']); // Housekeeping $boxHeading = BOX_HEADING_CATEGORIES; $corner_top_left = 'rounded'; $corner_top_right = 'rounded'; $corner_bottom_left = 'rounded'; $corner_bottom_right = 'rounded'; $boxContent_attributes = ''; $boxLink = ''; $box_base_name = 'categories'; // for easy unique box template setup (added BTSv1.2) $box_id = $box_base_name . 'Box'; // for CSS styling paulm (editted BTSv1.2) ob_start(); // Start output buffering displayCategories($categories); // Read categories into buffer $info_box_categories = ob_get_contents(); // Pass buffer contents to $info_box_categories ob_end_clean(); // Clear the buffer $boxContent = $info_box_categories; include bts_select('boxes', $box_base_name); // BTS 1.5