Hello to all Web Developers!

I need a simple help here:

<table class="maxWidth" cellspacing="0">
<form action="update_conditions.php" method="post" >
<tr>
<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>
</td></tr>
<tr><td>
<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

Recommended Answers

All 3 Replies

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

~G

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);
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.

~G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.