Problems with FOR loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Re: Problems with FOR loop

Post by kdidymus »

I should point out I ran your code exactly as you wrote it and the prefix for each name was 17!! That's the reason I've tried moving that section of the code slightly!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Problems with FOR loop

Post by Christopher »

kdidymus wrote:1) How would I sort the results by YEAR OF BIRTH? This is something I've been thinking about for a while but now that the results are in an array it SHOULD be easily done. I've researched usort, asort etc. but can't seem to get it to apply to my code!
Add " ORDER BY yearofbirth" to the end of the SQL.
kdidymus wrote:2) How do I ensure the prefix is an incremental number? At the moment every entry is shown as 01!! I think this is because the results are fetched as an array and "dumped" all at once.
Move $p=1 to outside, before the while loop. Obviously it was setting the value back to 1 each loop.
(#10850)
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Re: Problems with FOR loop

Post by kdidymus »

Thanks. Works like a charm. Using your loop code for spouses and siblings is throwing up a RESOURCE / BOOLEAN error but I think that's because of a lack of error trapping.

I'm well on my way!

Thank you again.
Post Reply