grantypap Posted May 8, 2007 Share Posted May 8, 2007 hey guys, i have a form for a php/mysql based online test. at present the code calls the questions and their unique ID's and puts the questions in a table and adds the ID as a hidden field. the problem that i am having is that im not sure how i am going to put the answers back in the DB. i cant just use the POST method because there may be hundreds of entry's so i was thinking of using 2 arrays, 1 for ID's and 1 for questions. ie. the first entry in ID_array will match the first entry in QUESTION_array. this would work fine but for some questions there can be more than one possible answer. do you think that multidimensional arrays may be the way to go? if so how would you suggest i implement this? Cheers, Grant Quote Link to comment https://forums.phpfreaks.com/topic/50492-multidimensional-arrays/ Share on other sites More sharing options...
taith Posted May 8, 2007 Share Posted May 8, 2007 personally... i'd run it like this... $array[1][question]='question'; $array[1][answer][]='answer1'; $array[1][answer][]='answer2'; then when you take em out... just foreach($array[1][answer] as $val) Quote Link to comment https://forums.phpfreaks.com/topic/50492-multidimensional-arrays/#findComment-248063 Share on other sites More sharing options...
grantypap Posted May 8, 2007 Author Share Posted May 8, 2007 how would i get the answers in their though? once the user has completed the test and hit submit would i still need grab their input and try and match it up with that array (on the script page)? i guess that everything needs to happen on the form because by the time it gets to the script it will all be out of order? im really stumped on this one!! cheers, Grant Quote Link to comment https://forums.phpfreaks.com/topic/50492-multidimensional-arrays/#findComment-248072 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.