954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Type="radio" | VERY SIMPLE |

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 
<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

artvor
Light Poster
29 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

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

Graphix
Posting Pro in Training
432 posts since Aug 2009
Reputation Points: 82
Solved Threads: 74
 

I never work befor with

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!

artvor
Light Poster
29 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

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

Graphix
Posting Pro in Training
432 posts since Aug 2009
Reputation Points: 82
Solved Threads: 74
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: