Query Results OK, Form Results Messed Up

I have a webpage/form where a user can change his/her ( @ralphm ) interests. It is a series of checkboxes.

The form is populated directly by a multidimensional array, and indirectly by a database query.

Because this script is complex - and my client’s - I can’t post it here.

Anyway, the problem is that ever since I replaced my dummy records with production data, the form results are in some wacked out sort order?! :hushed:

I did a var_dump on the multidimensional array that populates the form, and things look good there, but what I see when the page loads is off and in no easily identifiable pattern.

Things are a little tricky in that I have this outward appearance…

SPORTS                INDOORS
__ Football            __ Cooking
__ Basketball            __ Knitting
__ Baseball            __ Reading


OUTDOORS            COMMUNITY
__ Hunting            __ Volunteering
__ Fishing            __ Choir
__ Camping            __ Community Group
__ Hiking

…where the HTML is two columns.

Here is a tiny code snippet…

// Looks good here
var_dump($interestsDBArray);
exit();
                            // Iterate through array containing active Interests and checked info.
                            foreach($interestsDBArray as $key => $subArray){
// Is messed up starting here - I assume?!

I know this description is vague, but I am hoping this is some newbie mistake I’m making - maybe with multidimensional arrays?

1 Like

Show the sample of var_dump() output and your similar output with loop

1 Like

I just dumped my production data, loaded some new test data, and of course it works?!

Back to the drawing board…

1 Like

I figured it out!

In my code, I had hard-coded to start column #2 after the 3rd Category. (There is probably a better way to do this, but that’s for another day!)

Well, for my production data, I wanted Categories 1-4 in Column #1 and the rest in Column #2.

So having it still set for the test data and having Categories 1-2 in Column #1 and the rest in Column #2 caused some weird wrapping that gave what appeared to be random results.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.