如何将单选按钮值放在数据库中? [关闭]

I have to make a website for school and one of the tasks is to make a survey that storage values of radio buttons into a database and afterwards the user can get the values back from the database?

I want to use PHP to do this, can anyone help me please? Thanks!

Hopefully avoiding doing your homework for you, here's some help along the way.

http://php.net/manual/en/reserved.variables.post.php What you need to grab the value of your radio button

http://www.w3schools.com/sql/default.asp The language you need to input into an SQL db

http://www.w3schools.com/php/func_mysql_real_escape_string.asp So you don't break your databas

For the "store to the DB" part: The form returns the value of the checked radio button. You could store the string for example.

For the "retrieve from the DB" part: you could set the checked attribute of the radio button in an if statement if the value string matches the one from the DB.

You might want to have a look at the radio button syntax and to a simple polls application (yes, it's django, but it illustrates the DB model)...