Pergunta

I'm working on simple survey I need to store answers in mysql database.(I'm using radio button)

Foi útil?

Solução

Put a form with a radio in your html

<form action="submitTarget.php" method="post">
    <fieldset>
        <legend>Options:</legend>
        Option One   <input type="radio" name="optionSelected" value="one"/>
        Option Two   <input type="radio" name="optionSelected" value="two"/>
        Option Three <input type="radio" name="optionSelected" value="three"/>
        <input type="submit" value="Save" />
    </fieldset>
</form>

On your PHP side(if you use php) get the post value, construct you statement and execute it:

$selectedValue = $_POST["optionSelected"];
$statement = " INSERT INTO MyTable(option_name) VALUES($selectedValue) ";

Obviously this is to illustrate the principle you need to do a lot more if you want to create a nice product.

Cheers!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top