473,383 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Radio Groups

I have a database which holds data to say On or Off, i have a form with a
radio group called status. I can change the status and submit it to the
database fine. But how do u get the radio group to tell me if it's on or
off? by checking the correct button?
Thanks

--
Kathryn (Fire Juggler)
http://www.firejugglers.34sp.com
http://www.cornwalljugglers.co.uk
Jul 17 '05 #1
2 1557

You need to set the value attribute of the radio buttons to "On" and
"Off" or 1 and 0 respectively like so:

<input type="radio" name="status" value="1"> On <br>
<input type="radio" name="status" value="0"> Off <br>

When the form is posted, the value of the form variable 'status' will
be set according to the selection, so you just use that.

Hope this helps!

Fire Juggler wrote:
I have a database which holds data to say On or Off, i have a form with a
radio group called status. I can change the status and submit it to the
database fine. But how do u get the radio group to tell me if it's on or
off? by checking the correct button?
Thanks

--
Kathryn (Fire Juggler)
http://www.firejugglers.34sp.com
http://www.cornwalljugglers.co.uk


Jul 17 '05 #2
So for example:

<?php
$sql = "SELECT status FROM thequestion WHERE id = 42";
$res = mysql_query($sql);
if (!$res) {
db_error("Could not select status", $sql);
exit;
}
$row = mysql_fetch_assoc($res);
?>

Off <input type="radio" name="status" value="0" <?php if
(empty($row['status'])) echo 'CHECKED'; ?>> or
On <input type="radio" name="status" value="1" <?php if
(!empty($row['status'])) echo 'CHECKED'; ?>>

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Phil Powell | last post by:
<b>Agency 4</b> <input type="radio" name="permission" value="1" checked> Yes <input type="radio" name="permission" value="0" > No <br> <b>Agency 5</b> <input type="radio" name="permission"...
1
by: Michael Albanese | last post by:
I am developing an application to handle my compay's OSHA reporting requirements. Some of the input criteria are technical and narowly defined, so I was trying to prvide what i call "Context...
15
by: tabonni | last post by:
I want to check each button groups and save the checked value into a 2 dimensional array. But, it doesn't work. Could anyone tell me what's wrong with my code. My code is as follow: <html>...
2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
33
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give...
3
by: Amelyan | last post by:
When we want radio button to belong to a group name we say, radio1.GroupName="GroupA". In this case, radio1 will be unselected if another radio button is selected in "GroupA". Is there a way...
1
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.