<?php
$nav_query = mysql_query("SELECT * FROM `cm2year` ORDER BY `catid`");
$tree = ""; // Clear the directory tree
$depth = 1; // Child level depth.
$top_level_on = 1; // What top-level category are we on?
$exclude = array(); // Define the exclusion array
array_push($exclude, 0); // Put a starting value in it
while ( $nav_row = mysql_fetch_array($nav_query) )
{
$goOn = 1; // Resets variable to allow us to continue building out the tree.
for($x = 0; $x < count($exclude); $x++ ) // Check to see if the new item has been used
{
if ( $exclude[$x] == $nav_row['catid'] )
{
$goOn = 0;
break; // Stop looking b/c we already found that it's in the exclusion list and we can't continue to process this node
}
}
if ( $goOn == 1 )
{
$tree .= "Year". $nav_row['catname'] . "<br>"; // Process the main tree node
array_push($exclude, $nav_row['catid']); // Add to the exclusion list
if ( $nav_row['category_id'] < 6 )
{ $top_level_on = $nav_row['catid']; }
$tree .= build_child($nav_row['catid']); // Start the recursive function of building the child tree
}
}
function build_child($oldID) // Recursive function to get all of the children...unlimited depth
{
global $exclude, $depth; // Refer to the global array defined at the top of this script
$child_query = mysql_query("SELECT * FROM `cm3model` WHERE parentid=" . $oldID);
while ( $child = mysql_fetch_array($child_query) )
{
if ( $child['catid'] != $child['parentid'] )
{
for ( $c=0;$c<$depth;$c++ ) // Indent over so that there is distinction between levels
{ $tempTree .= " "; }
$tempTree .= "options[" . $child['parentid'] ."]". "=new Option" . "(\"" . $child['catname'] ."\"" . "," . "\"http://www.intimegraphics.com/category_s/" . $child['catid']. ".htm\")<br>";
$depth++; // Incriment depth b/c we're building this child's child tree (complicated yet???)
$tempTree .= build_child($child['catid']); // Add to the temporary local tree
$depth--; // Decrement depth b/c we're done building the child's child tree.
array_push($exclude, $child['catid']); // Add the item to the exclusion list
}
}
return $tempTree; // Return the entire child tree
}
echo $tree;
?>
.
Tuesday, 12 August 2014
Subscribe to:
Post Comments (Atom)
.
Popular Posts
-
You can follow these instructions if you need to manually perform a phpBB installation for your web site. Note that you should skip this s...
-
Conversion rates actually increase if you use other terminology for the button text. According to Hubspot , you can increase your convers...
-
Joomla is one of the most popular Content Management Systems (CMS) in the world, used in over 30 million sites, with over 200,000 communi...
-
Types of Encryption - Conventional Methods Encryption - Decryption: To carry sensitive information, such as military or financial data, a sy...
-
In this SMF introductory installation tutorial, we will demonstrate how to install the Simple Machine Forums (SMF) program manually. A man...
-
Simple Login logout system using php Login and logout system is the most important thing for the user management, session management is on...
-
Try Joomla 3 Now! We’ve partnered with Siteground to provide a 90-day free Joomla! demo account . Get an instant Joomla website today! Try ...
-
CSS3 Animations With CSS3, we can create animations, which can replace animated images, Flash animations, and JavaScripts in many web pages....
-
As a PHP developer, we often get bored with one PHP framework and looks for some advanced feature rich framework which can make life easie...
-
WEBDEC Technologies The penetration of web and digital media into every aspect of people’s lives has caused fundamental changes in how peo...
Powered by Blogger.
0 comments:
Post a Comment