View Full Version : while loop in a function
harmor19
13 Nov 2005, 07:52
I am doing the hook system in my own scripts but I have a small problem.
It only returns the first hook that matches $hook_name.
How do I have it return all the rows where the hook_names match?
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Marco van Herwaarden
13 Nov 2005, 19:03
A 'return' statement leaves the function and returns control to the calling script.
harmor19
13 Nov 2005, 19:48
So I'll need to check if I got every field where hook_name = $hook_name?
I don't know how to do this offhand, hopefully I'll find it easily.
Marco van Herwaarden
13 Nov 2005, 20:52
No, you should not return there. Instead you would probably want to evaluate the code you have just read from the database.
harmor19
13 Nov 2005, 21:12
It occured to me that I was using return in the while loop so I took it out of the while loop and now it works.
That's another lesson learned.
Thanks for the help though.
Marco van Herwaarden
13 Nov 2005, 21:20
Well that was my first answer. ;)
harmor19
13 Nov 2005, 21:21
Well that was my first answer. ;)
I didn't interpret it like that.
The Geek
13 Nov 2005, 21:45
Think you want something like this:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
for a more vb3.5 approach (with cleansing, etc...) try this:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Havent tested either - but they should work fine for you.
nJoy
vBulletin® v3.6.12, Copyright ©2000-2013, Jelsoft Enterprises Ltd.