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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 18th, 2004, 11:15 AM
kfazi kfazi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 10 kfazi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 4 sec
Reputation Power: 0
[help please] recursive functions in PHP with MySQL

Hi all
Maybe it's stupid question but I don't know how to do it
I've got Mysql table (it's menu structure):
id | parent_id | name

and i want to build menu from that table, but i have to use recursive function. So the problem is: how to build this resursive function? I mean: do i have to use mysql_connect(host,user,pass) and so on in this function? Because if i use this each calling of this function makes new myslq_connection...

How to write recursive function using only one connection...

Thank you for help

Reply With Quote
  #2  
Old September 19th, 2004, 02:27 AM
oyejorge oyejorge is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 oyejorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 13 sec
Reputation Power: 0
mysql_connect does not need to be inside your recursive function.

$connection = mysql_connect(...);
and use $connection within the recursive function.

Reply With Quote
  #3  
Old September 19th, 2004, 01:01 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 5
It is worth baring in mind that you cannot use variables declared outside a function unless you declare them as global at the top of the function or pass them in as a parameter.

-KM-

Reply With Quote
  #4  
Old September 20th, 2004, 11:05 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
If possible, present some of your code. Perhaps we can help ya sort it out.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > [help please] recursive functions in PHP with MySQL


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 6 hosted by Hostway