Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:34:10+00:00 2026-06-15T09:34:10+00:00

I am trying to make a variable yes/no radio type. My script is: while

  • 0

I am trying to make a variable yes/no radio type.
My script is:

                while ($row1 = mysql_fetch_assoc($vragen))
                {
                    $type = $row1['type'];
                    if ($type == 'kort')
                        {
                    echo '
                        <tr>
                            <td width="60%">'
                                .$row1['vraag'].'
                                <input type="hidden" name="vragen'.$aantalBranches.'[]" value="'.$row1['vraag'].'"/>
                            </td>
                            <td>
                            <input type="text" name="antwoorden'.$aantalBranches.'[]"/>
                            </td>
                        </tr>';
                        }
                    elseif ($type == 'lang')
                    {
                    echo '
                        <tr>
                            <td width="60%">'
                                .$row1['vraag'].'
                                <input type="hidden" name="vragen'.$aantalBranches.'[]" value="'.$row1['vraag'].'"/>
                                </td>       
                        <td><textarea name="antwoorden'.$aantalBranches.'[]" cols="30"rows="5"></textarea><td/>
                        </tr>';

                    }
                    elseif ($type == 'ja,nee')
                        {
                        echo'
                        <tr>
                            <td width="60%">'
                                .$row1['vraag'].'
                                </td>
                            <td>
                                <input type="radio" name="optie'.$c.'"  value="yes">Yes
                                <input type="radio" name="optie'.$c.'"  value="no">No  
                            </td>';

                            if ('optie'.$c.'' == 'yes')
                                {
                                echo'
                                <td><input type="hidden" name="vragen'.$aantalBranches.'[]" value="'.$row1['vraag'].'"/></td>
                                <td><input type="text" name="antwoorden'.$aantalBranches.'[]" value="yes"/></td>
                                </tr>';
                                }
                            else
                            {
                            echo'
                            <td><input type="hidden" name="vragen'.$aantalBranches.'[]" value="'.$row1['vraag'].'"/></td>
                            <td><input type="text" name="antwoorden'.$aantalBranches.'[]" value="no"/></td>
                            </tr>';
                            }

                        $c++;

                    }


                }

            echo '</table>';
            $aantalBranches++;
    }

The problem is that i want the result stored in 1 variable the $antwoorden [] so the most logic way was a if else for this but for a strange reason it doesn’t work any1 can help me ?
It now only shows “no” even if i change it to “yes”.
I edited the script and added the other choises of the form long and short fields(textarea/inputfield)
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:34:11+00:00Added an answer on June 15, 2026 at 9:34 am
    if ('optie'.$c.'' == 'yes')
    

    This part will always evaluate to false.

    You probably don’t know how this variable is going to be named because name depends on value from variable $c and this is what is giving you difficulties.

    To overcome this you could just pull all of the variables that start with ‘optie’ string and then cycle through them when you want to use them. You can also access this variable like this.

    $optionname = 'optie'.$c;
    $optionvalue = $$optionname;
    // or
    $optionvalue = $_POST[$optionname];
    

    But generally speaking looking at your code it is very badly structured and I would consider restructuring that code. But without more context I can’t give you more instructions on how to do this.

    Update:

    Just change mentioned condition to:

    if ($_POST['optie'.$c] === 'yes')
    

    Or change $_POST to $_GET if you are using ‘GET’ http request to pass ‘optie’ variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a variable which contains some HTML tags, this isn't
I'm trying to make one word (variable) of a message box bold in my
So I'm trying to make a registration page that feeds back a variable when
I'm trying to make a ggplot graph wich show the proportions of a variable
I'm trying to make a SPARQL query, that returns a variable which contains two
I am trying to make a class from a member variable like this: <?
I am trying to make a variable that I can increment each time after
I'm trying to make a variable sized array in c. The array keeps on
I've been trying to make this work for a while now with no chance,
I'm trying to make a global variable, initialized in my msh.c file as: volatile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.