Jump to content

how to check which question is selected


tomjerry

Recommended Posts

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.