tomjerry Posted April 5, 2013 Share Posted April 5, 2013 Hi, I am trying to do the coding for the or choice questions. What i am trying to do is like, i am having set of questions in a form with some image.By clicking the image calls other page with textarea to answer and there views the or choice question like 1a.who am i? or 1b. what do you do? At the end of both questions i have set some other image. Now what i am trying to do is, i have to chech whether i have selected 1a or 1b, then the written answer have to get save in data base with the appropriate qnumber. Please tell me how to check which question is selected. Quote Link to comment https://forums.phpfreaks.com/topic/276556-how-to-check-which-question-is-selected/ Share on other sites More sharing options...
exeTrix Posted April 5, 2013 Share Posted April 5, 2013 If the question being displayed relates directly to the image that has been selected, then you can add a GET parameter to the URL. Eg. /form.php?selection=1 and /form.php?selection=2 Then in your PHP: if( !isset( $_GET['selection'] ) ){ //display an error to the user as they've reached the page without making a selection }else{ $selection = (int) $_GET['selection']; if( $selection === 1 ){ //display 1a form }elseif( $selection === 2 ){ //display 1b form }else{ //display invalid selection error } } With regards to saving to the database there are a lot of resources online showing you how to do this. Any problems then give me a shout Quote Link to comment https://forums.phpfreaks.com/topic/276556-how-to-check-which-question-is-selected/#findComment-1423016 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.