Bug #1975: A recursive function is not acting correctly in 4.0b2 that works fine in 3.0
| From: | mstearne at eisolutions dot com | Date: | Thu, 05 Aug 1999 17:30:41 +0000 |
| Subject: | Bug #1975: A recursive function is not acting correctly in 4.0b2 that works fine in 3.0 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-9570@lists.php.net to get a copy of this message | ||
From: mstearne@eisolutions.com
Operating system: Linux 2.2.5 (RH 6)
PHP version: 4.0 Latest CVS (05/08/1999)
PHP Bug Type: Other
Bug description: A recursive function is not acting correctly in 4.0b2 that works fine in 3.0
This function should (and does in 3.0) output
* Computers
* Desktops
* Notebooks
* Hand Held
* Video Games
for and number of levels of Cat/Sub-Categories.
In 4.0 the output is
* Computers
* Video Games
This also affects other functions that were built out of code like this.
<pre>
# --------------------------------------------------------
#
# Table structure for table 'category'
#
CREATE TABLE category (
ID int(5) unsigned DEFAULT '0' NOT NULL auto_increment,
Name varchar(255) NOT NULL,
Description varchar(255) NOT NULL,
ParentID int(5) unsigned DEFAULT '0' NOT NULL,
LImage varchar(128),
MImage varchar(128),
SImage varchar(128),
PRIMARY KEY (ID),
KEY Description (Description)
);
#
# Dumping data for table 'category'
#
INSERT INTO category VALUES( '2', 'Desktops', '', '1',
'DefaultCatLarge.gif', 'DefaultCatMedium.gif', 'DefaultCatSmall.gif');
INSERT INTO category VALUES( '1', 'Computers', '', '0',
'DefaultCatLarge.gif', 'DefaultCatMedium.gif', 'DefaultCatSmall.gif');
INSERT INTO category VALUES( '3', 'Notebooks', '', '1',
'DefaultCatLarge.gif', 'DefaultCatMedium.gif', 'DefaultCatSmall.gif');
INSERT INTO category VALUES( '14', 'Video Games', '', '0',
'DefaultCatLarge.gif', 'DefaultCatMedium.gif', 'DefaultCatSmall.gif');
INSERT INTO category VALUES( '13', 'Hand Held', '', '1',
'DefaultCatLarge.gif', 'DefaultCatMedium.gif', 'DefaultCatSmall.gif');
################################################################
</pre>
<?
$CS_HELP_EMAIL="help@127.0.0.1";
$CS_SERVERNAME="127.0.0.1";
$CS_SCRIPTNAME=basename($PHP_SELF);
$CS_DBHOST="127.0.0.1";
$CS_DBUSER="blaze";
$CS_DBPASS="johnny";
$CS_DATABASE="test_cs";
$CS_FONTATTRIBUTES="";
function mySiteMap($ShowDescription="",$me=0) {
global $CS_SCRIPTNAME,$CS_DBHOST,$CS_DBUSER,$CS_DBPASS
global $CS_DATABASE,$CS_FONTATTRIBUTES;
global $MSM_QUERY,$IS_SUBMAP;
global $final,$CatName,$CatDescription;
if(!$MSM_QUERY){
mysql_connect($CS_DBHOST,$CS_DBUSER,$CS_DBPASS);
$q=mysql_db_query($CS_DATABASE,"select * from category");
unset($final);
while($result=mysql_fetch_object($q)):
$final[$result->ParentID][] = $result->ID;
$CatName[$result->ID] = $result->Name;
$CatDescription[$result->ID] = $result->Description;
endwhile;
mysql_free_result($q);
$MSM_QUERY=1;
}
if (is_array($final[$me])):
echo '<ul>';
print "\n";
while (list(,$child)=each($final[$me])):
if($me==0){ // Top Level Category
echo '<br><li type=DISC>';
echo '<a
href="showMyCats.php3?InID='.$child.'">'.$CatName[$child].'</a>';
echo '</li>';
print "\n";
}else{ // NOT Top Level Category, A Sub Cat
echo '<li type=CIRCLE>';
echo '<a
href="showMyCats.php3?InID='.$child.'">'.$CatName[$child].'</a>';
echo '</li>';
echo '<br>';
print "\n";
}
mySiteMap($ShowDescription,$child);
echo "";
endwhile;
echo "</ul>\n";
endif;
}
mySiteMap();
?>