Ok so I know it’s not PHP’s fault but for the past 2 hours I’ve been working on a script and I’m getting nowhere. I’ve been working on this project for about 2 weeks now and this is the first real problem I’ve come across. I just can’t seem to get it right. Let me explain…
I have two tables - ‘modules’ and ‘user_modules’.
The ‘modules’ table basically consist of an ‘ID’ and ‘filename’ column. The ‘user_modules’ table consists of ‘ID’, ‘userID’, ‘moduleID’, ‘order’ and ‘location’.
The basic idea behind the script is to allow the user to select which modules he/she wants to display on a page and in what order. There are 3 possible locations for the modules which I am identifying with numbers 1, 2 and 3 in the ‘location’ column.
On my page I first have a query to the database which is pulling every row from the ‘user_modules’ table as well as those from the ‘modules’ table where ‘user_modules.moduleID’ equals ‘modules.ID’. I have then built this into an array with this structure.
$modules[location][filename]
Then in the three different locations (1, 2 and 3) I am using a foreach loop to loop through the $modules[location] array so I can get out all of its filenames. The files are then included one by one. The problem though is that in location 1 it works fine, in location 2 only the first file is being included and in location 3 none at all.
I cant quite get my head around it right now and its annoying me. If you have any suggestions as to what could be causing this let me know.
Ill keep trying…




July 27th, 2007 at 8:53 am
I also have this same problem with PHP
July 27th, 2007 at 4:24 pm
haha, sure you do :p
November 5th, 2007 at 6:36 pm
I see this is an older post, so undoubtedly you’ve solved this one by now, but a couple of tips:
1. print_r() to print the contents of your $modules array, so see what is actually getting loaded into the array.
2. Post source code so that others can pin-point and learn from the problem you are having.
Best regards
November 6th, 2007 at 10:38 am
Thanks for the reply but yes, I have already solved this problem. It was quite a while ago but if I remember correctly I had a function which was messing with the $modules array so once I cleared that up it worked like a charm.