Re: [PHP] Recursion... Sort of...

2008-05-09 Thread tedd
At 5:48 PM -0400 5/8/08, Matt Neimeyer wrote: Is there a way to tell if a function has been called that has resulted in a call to the same function? We have an in-house CRM app that has a function that draws a tabbed panel on a screen... BUT if there are sub-sub-tabbed panels we want to invert t

Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Matt Neimeyer
Wow! Thanks guys! Here's what I ended up doing... To get... Black on White - 1 White on Black - 2 Black on White - 3 Black on White - 3 White on Black - 2 Black on White - 3 I had to do something like... function doStuff() { static $callCount = 0; $callCount++; if($c

Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Nathan Nobbe
On Fri, May 9, 2008 at 1:52 AM, Stut <[EMAIL PROTECTED]> wrote: > On 9 May 2008, at 02:02, Nathan Nobbe wrote: > >> function doStuff() { >> static $callCount; >> >> if(!isset($callCount)) >> $callCount = 1; >> else >> $callCount++; >> >> /// do stuff w/ $callCount to potentially handle sub-tabs

Re: [PHP] Recursion... Sort of...

2008-05-09 Thread Stut
On 9 May 2008, at 02:02, Nathan Nobbe wrote: function doStuff() { static $callCount; if(!isset($callCount)) $callCount = 1; else $callCount++; /// do stuff w/ $callCount to potentially handle sub-tabs and stuff if($callCount == 2) { echo 'white on black'; } else { echo 'black

Re: [PHP] Recursion... Sort of...

2008-05-08 Thread Nathan Nobbe
On Thu, May 8, 2008 at 6:23 PM, Jim Lucas <[EMAIL PROTECTED]> wrote: > Nathan Nobbe wrote: > >> On Thu, May 8, 2008 at 3:48 PM, Matt Neimeyer <[EMAIL PROTECTED]> wrote: >> >> Is there a way to tell if a function has been called that has resulted >>> in a call to the same function? >>> >>> We have

Re: [PHP] Recursion... Sort of...

2008-05-08 Thread David Otton
2008/5/8 Matt Neimeyer <[EMAIL PROTECTED]>: > Is there a way to tell if a function has been called that has resulted > in a call to the same function? debug_backtrace() Can't comment on performance, though. Its an inelegant solution. > We have an in-house CRM app that has a function that draws

Re: [PHP] Recursion... Sort of...

2008-05-08 Thread Jim Lucas
Nathan Nobbe wrote: On Thu, May 8, 2008 at 3:48 PM, Matt Neimeyer <[EMAIL PROTECTED]> wrote: Is there a way to tell if a function has been called that has resulted in a call to the same function? We have an in-house CRM app that has a function that draws a tabbed panel on a screen... BUT if th

Re: [PHP] Recursion... Sort of...

2008-05-08 Thread Nathan Nobbe
On Thu, May 8, 2008 at 3:48 PM, Matt Neimeyer <[EMAIL PROTECTED]> wrote: > Is there a way to tell if a function has been called that has resulted > in a call to the same function? > > We have an in-house CRM app that has a function that draws a tabbed > panel on a screen... BUT if there are sub-su

Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 11:23 am, Tony Di Croce wrote: > I have to write some PHP backend code for a threaded message board. > The db > has a message table, and each message has a parent id. > > Does anyone have any advice for someone whos never done this in PHP? > > I'm currently thinking that I w

Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Børge Holen
On Friday 10 August 2007 18:29, Stephen wrote: > --- Tony Di Croce <[EMAIL PROTECTED]> wrote: > > I have to write some PHP backend code for a threaded > > message board. The db > > has a message table, and each message has a parent > > id. > > > > Does anyone have any advice for someone whos never

Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Richard Davey
Hi Tony, Friday, August 10, 2007, 5:23:28 PM, you wrote: > I have to write some PHP backend code for a threaded message board. > The db has a message table, and each message has a parent id. > Does anyone have any advice for someone whos never done this in PHP? > I'm currently thinking that I w

Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Stephen
--- Tony Di Croce <[EMAIL PROTECTED]> wrote: > I have to write some PHP backend code for a threaded > message board. The db > has a message table, and each message has a parent > id. > > Does anyone have any advice for someone whos never > done this in PHP? You are reinventing the wheel here. Wh

RE: [PHP] Recursion: Ugh!

2005-05-27 Thread Chris W. Parker
Steve Brown on Friday, May 27, 2005 2:17 PM said: > So in your case, if you wanted to create a new item in the category > "Round", you would first have to navigate to Food > Vegetables > > Round, then create the new item. This may seem more complicated, > but think

Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Steve Brown
** email gagging, sorry if this is a DP ** On 5/27/05, Chris W. Parker <[EMAIL PROTECTED]> wrote: > Let's say you're entering a new product, you'd want to see a list of all > the available categories, not just the last node of a branch. Not neccesarily; it depends on how big your tree structure i

Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Steve Brown
On 5/27/05, Chris W. Parker <[EMAIL PROTECTED]> wrote: > Let's say you're entering a new product, you'd want to see a list of all > the available categories, not just the last node of a branch. Not neccesarily; it depends on how big your tree structure is. If you only have 10 "categories" where a

RE: [PHP] Recursion: Ugh!

2005-05-27 Thread Chris W. Parker
Steve Brown on Thursday, May 26, 2005 11:47 AM said: > How is your structure being built? Is it hard-coded or dynamic (e.g. > pulled from a DB)? >From a database. > We employ a similar "tree" structure for manging > items in our store front. Believe me when I say

Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Steve Brown
> Food:Fruit:Red > Food:Fruit:Green > Food:Fruit:Yellow > Food:Vegetables:Long > Food:Vegetables:Round > Food:Vegetables:Round:Spikey > Food:Vegetables:Round:Smooth How is your structure being built? Is it hard-coded or dynamic (e.g. pulled from a DB)? We employ a similar "tree" structure for ma

Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Chris
Chris W. Parker wrote: Hi everyone, I've been working on a problem for a few days now and I'm not making any headway so I think it's time I come to the list for some help (though this really disappoints me since it appears I'm not capable of solving this problem on my own!). Anyway, I'm using

Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Chris
Chris W. Parker wrote: Hi everyone, I've been working on a problem for a few days now and I'm not making any headway so I think it's time I come to the list for some help (though this really disappoints me since it appears I'm not capable of solving this problem on my own!). Anyway, I'm using

Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Chris
Chris W. Parker wrote: Marek Kilimajer on Thursday, May 26, 2005 11:35 AM said: untested: function display($array, $prefix = '') { echo $prefix ':' . $array['name'] . "\n"; if(is_array($array['children']) && $array['children']) {

Re: [PHP] Recursion: Ugh!

2005-05-26 Thread Rory Browne
This would have been easier if you'd posted the php code to create the array, as opposed to the output of print_r. I did this: 'food', 'children' => array( array( 'name' => 'meat', 'children' =>

RE: [PHP] Recursion: Ugh!

2005-05-26 Thread Chris W. Parker
Marek Kilimajer on Thursday, May 26, 2005 11:35 AM said: > untested: > > function display($array, $prefix = '') { > echo $prefix ':' . $array['name'] . "\n"; > if(is_array($array['children']) && $array['children']) { > foreach($array['child

Re: [PHP] Recursion: Ugh!

2005-05-26 Thread Marek Kilimajer
Chris W. Parker wrote: Hi everyone, I've been working on a problem for a few days now and I'm not making any headway so I think it's time I come to the list for some help (though this really disappoints me since it appears I'm not capable of solving this problem on my own!). Anyway, I'm using t

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread zooming
Hi Comex Thanks! That worked! Robet you almost had it but missing the $key in $newvalue[$key]. - Original Message - From: "Comex" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 08, 2004 8:05 PM Subject: Re: [PHP] Recursion to sanitize

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Comex
foreach ( $userInput as $key => $value ) { $newvalue[$key] = sanitize( $value ); } return $newvalue; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Robet Carson
this would probably be even better: foreach ( $userInput as $key => $value ) { $newvalue[$key] = sanitize( $value ); // reassign key with sanatized value } return $newvalue // return array with sanatized $key => $value pairs } else My 2 cents: -- PHP General Mailing

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Robet Carson
it should be this i think: foreach ( $userInput as $key => $value ) { $newvalue[] = sanitize( $value ); } return $newvalue // returns an array - since this is the only way to get all veriables from the function } else I could be wrong but the only way it woul

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Curt Zirzow
* Thus wrote Yoed Anis: > Simple your code should look like this: > > ... > if ( is_array($userInput) ) > { > foreach ( $userInput as $key => $value ) > { > return sanitize( $value ); //< needed to return it or > else its not recurssive This is wrong, o

RE: [PHP] Recursion to sanitize user input

2004-10-08 Thread Yoed Anis
Simple your code should look like this: ... if ( is_array($userInput) ) { foreach ( $userInput as $key => $value ) { return sanitize( $value ); //< needed to return it or else its not recurssive } } else { ... . Should work, not tes

Re: [PHP] Recursion help?

2004-09-19 Thread Gerard Samuel
Marek Kilimajer wrote: your children function can return only one child, and one parent can have more children. You should create an array of all children and loop that. As always, thanks for the nudge in the right direction. I was in the middle of rewriting it, and applied your suggestion to it

Re: [PHP] Recursion help?

2004-09-19 Thread Marek Kilimajer
your children function can return only one child, and one parent can have more children. You should create an array of all children and loop that. Gerard Samuel wrote: Im trying to dynamically construct a multidimensional array to be used with PEAR's HTML_Menu. http://pear.php.net/manual/en/pack

Re: [PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
Hi all, Thanks for your help. I now have a wealth of things to try - I was initially going for the bottom up approach by starting at the bottom of the tree and working up, but I quite like the idea of storing id's in an array or list, although this would mean two queries to the DB. I am still

Re: [PHP] Recursion with database tables

2003-02-19 Thread Ernest E Vogelsinger
At 14:56 19.02.2003, Jono Bacon spoke out and said: [snip] >The code that you posed is the technique I have used at the moment. This >technique works fine, but like my mate said, this limits me to a single >parent for a comment/message. I admit that is unli

Re: [PHP] Recursion with database tables

2003-02-19 Thread Ernest E Vogelsinger
At 15:16 19.02.2003, Jono Bacon spoke out and said: [snip] >How would I go about recursing down the tree? Has anyone done this before? [snip] Given the DB layout I sketched before, you would: 1) delete all comments d

Re: [PHP] Recursion with database tables

2003-02-19 Thread David Otton
On Wed, 19 Feb 2003 14:16:47 +, you wrote: >>Otherwise, yes, in MySQL you have to recurse down the tree deleting >>comments. >How would I go about recursing down the tree? Has anyone done this before? I have, but it's been a while. Something like (pseudo-code) . def delete_comments(a) :

Re: [PHP] Recursion with database tables

2003-02-19 Thread rblack
Jono Bacon ahoo.co.uk> cc:

Re: [PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
David Otton wrote: On Wed, 19 Feb 2003 13:56:49 +, you wrote: One questions though - if I delete a topic, I need to delete all of its child messages and all of the child comments from each message. What is the best technique to do this? This has been driving me up the wall as it seems

Re: [PHP] Recursion with database tables

2003-02-19 Thread David Otton
On Wed, 19 Feb 2003 13:56:49 +, you wrote: >One questions though - if I delete a topic, I need to delete all of its >child messages and all of the child comments from each message. What is >the best technique to do this? This has been driving me up the wall as >it seems to involve some kind

Re: [PHP] Recursion with database tables

2003-02-19 Thread Jono Bacon
Ernest E Vogelsinger wrote: At 14:43 19.02.2003, Jono Bacon said: [snip] At the moment I have three tables: Topic, Message, Comment. A topic has messages and each message can have comments. I have set this up with a table each and a field for the id of

Re: [PHP] Recursion with database tables

2003-02-19 Thread Ernest E Vogelsinger
At 14:43 19.02.2003, Jono Bacon said: [snip] >At the moment I have three tables: Topic, Message, Comment. A topic has >messages and each message can have comments. I have set this up with a >table each and a field for the id of the parent (e.g. a comment wi

RE: [PHP] recursion?????

2003-02-14 Thread David Freeman
> What I want to do is have the registration form, on submit, check the > data validity right then, if there is an error, redisplay > the form with an * next to the field that is incorrect. This is the code logic rather than the actual working code: ---Start of PHP Page--- 1. Check for form h

Re: [PHP] recursion?????

2003-02-14 Thread Bas Jobsen
not tested > Basically, have the form action call itself hince the recursion. > Any suggestion/examples? method="POST"> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Recursion

2001-10-01 Thread Sheridan Saint-Michel
Recursion means you call a function which calls itself to get the job done. Recursive functions have two parts, the base case and the recursive method. The base case is the goal which signals that your function stops calling itself... sort of like the condition in a while loop... but for a functio