Hello to all Web Developers!

I need a simple help here:

<table class="maxWidth" cellspacing="0">
<form action="update_conditions.php" method="post" >
<td ><input type="radio" name="sex" value="citizenship" checked="checked" /> 
Accept all citizenships <br />
<div class="paddT5 borderT"></div>
<input type="radio" name="sex" value="citizenship" /> We do not accept citizenships from: <textarea name="ud_not_citizenship" class="textarea"  rows="5"    > <? echo "$description" ?> </textarea>
<input type="Submit" value="Update conditions"></td></tr></table></form>

I need something like this:
If it's checked "Accept all citizenships " Show = Accept all citizenships
If it's checked "We do not accept citizenships from:" Show= textarea(details)

How can i add radio to a MYSQL db and then show data to PHP page.

Thanks to all :S

7 Years
Discussion Span
Last Post by Graphix

You just simply have a table, which only consists out of one row and some columns that represent settings:

CREATE TABLE settings (
accept_all_citizenship CHAR(3) DEFAULT "yes",
ud_not_citizenship LONGTEXT,
... And some other cols....

And just simply update that with the values returned from the form. Note that the names of your radio-inputs are weird, shouldn't they be 'accept_all_citizenship', and then the values 'yes' and 'no'?

I assume you know how to (My)SQL and PHP works with form handling and executing queries, else I refer you to the reference: http://php.net



I never work befor with <input type="radio" />

I have change values to yes/no

What is the MYSQL and PHP code to:

If yes = display = Accept all citizenships
If no = display = We do not accept citizenships from: (textare $description)

Thanks for helping me!


I assume you are making a admin area, and this is a setting that determines whether someone from any country can be accepted or from some countries not.

You retrieve the values and save them in the database:

// Retrieving the form values, and cleaning them from HTML and quotes

$accept_all_citizenship = htmlentities(mysql_real_escape_string($_POST['accept_all_citizenship']));
$ud_not_citizenship = htmlentities(mysql_real_escape_string($_POST['ud_not_citizenship']));

// Updating the table

$query = "UPDATE settings SET accept_all_citizenship='".$accept_all_citizenship."', ud_not_citizenship='".$ud_not_citizenship."'";
$result = mysql_query($query);

And then you retrieve its value on the page which has the form for people that want to apply, and check whether the citizenship is accepted. If you do not know how to do this, I strongly recommend you to read a bit more books on MySQL and PHP.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.