PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 5th, 2005, 03:57 PM
atatum atatum is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 3 atatum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 49 sec
Reputation Power: 0
Help with Recursion and mysql db

Hi All,

Hoping someone can lend a hand and point me in the right direction.

I have a mysql db with table for dynamically generated menu items. I have used the sothink javascript menu's to create the look and feel.

The problem I have is with the recursive function to get the items from the db. I cannot seem to be able to get beyond the second level and anything that has a parent of a parent wil not display.

My db setup is as follows:

id
name
link
mouseover
parentid
orderid

Thanks for your thoughts and suggestions.

This is my code (ignore the stm() stuff, this is the javascript functions):

Quote:
<script type="text/javascript" language="JavaScript1.2">
<!--
stm_bm(["menu2c5d",400,"","../images/blank.gif",0,"","",0,0,250,0,1000,1,0,0,""],this);

<?
$sLevelid = 0;
function outputtable($db_name, $sLevelid)
{
?>
stm_bp("p0",[1,2,0,0,2,2,0,7,100,"",-2,"",-2,50,0,0,"#ffffff","#ffffff","",3,1,1,"#00725d"]);
<?
$list_content = mysql_db_query($db_name, "SELECT * FROM menu WHERE parentid = $sLevelid ORDER BY orderid");

$numrowsCat = mysql_num_rows($list_content);

for($i=0, $j = $numrowsCat; $i<$j; $i++)
{
//
$rowCat = mysql_fetch_array($list_content);

$sName = $rowCat["name"];
$sNotes = $rowCat["mouseover"];
$sLink = $rowCat["link"];
$sParent = $rowCat["parentid"];
$sLevelid = $sLevelid+1;
?>

stm_ai("p1i0",[0,"<?=$sName?>","","",-1,-1,0,"index.php?page=<?=$sLink?>","_self","index.php?page=<?=$sLink?>","<?=$sNotes?>","","",0,0,0,"<? if($sSubTable)echo "images/arrow_r.gif" ?>","<? if($sSubTable)echo "images/arrow_r.gif" ?>",7,7,0,0,1,"#ffffff",0,"#D6EAE6",0,"","",3,3,0,0,"#ffffff","#00725d","#00725d","#00725d","bold 8pt Verdana","bold 8pt Verdana",0,0]);

<?

if ($sParent == "0")
{
outputtable($db_name, $sLevelid);

}
if ($i <= $j -2)
{
?>
stm_ai("p1i1",[6,2,"#00715a","",-1,-1,0]);
<?
}
}

?>

stm_ep();

<?
}

$dbhost = "localhost";
$dbusername = "test";
$dbpass = "test";
$dbname = "test";
$connection = mysql_connect($dbhost, $dbusername, $dbpass);

outputtable($dbname, $sLevelid);

?>

stm_em();
//-->
</script>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help with Recursion and mysql db


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT