Reply
Adding radio button fields to database..
Old 11-24-2004, 12:50 AM Adding radio button fields to database..
lothop's Avatar
Ultra Talker

Posts: 269
Hi, Just wondering if it was possible to add more than 1 variable to the same database table.

For example.

They hit the radio button 1. and radio button 2.

So now they have selected 1 and 2, then they hit send.

it then stores the value for 1, and the value for 2, into the same database table.

So, if it stores the information in the field " Rectangle " in the field " Rectangle " it will have stored 1 2.

Any ideas?
Lothop
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-24-2004, 08:27 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Lothop,

I am not entirely clear on your question. Firstly, radio buttons are by definition selectable only one at a time within a logical group. Their very name comes from the old manual preset buttons so common on car radios up until the early 1980's.

Assuming you mean checkboxes or some other means of specifying more than one value, let me try to restate your problem. With two values, you wish to be able to communicate, in one field that the user may have selected one option (we'll call the value for that option 1), another option (2), both or none. It's a common problem and programmers will normally approach it in one of several ways.

First, you could simply store off a comma-delimited list of the values selected. So if the user selected both, you would store "1,2" in the field.

Another option would be to assign numeric values to each option that are a power of 2. So option 1 would be 1, option 2 would be 2, option 3 would be 4, option 4 would be 8, then 16, 32, 64, etc. In this way, you could add all the values together and store that one numeric value from which could be deduced all the options selected. For example, if I store off a value of 11, I know a user must have selected a combination of options carrying the values of 1,2 and 8. That is the only combination of such values arriving at the sum of 11. It is really a matter of personal choice you wish to take.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 11-25-2004, 04:08 AM
lothop's Avatar
Ultra Talker

Posts: 269
I mean check boxes, not radio boxes.

Basically, so... it stores the selected box values in the same field.

So they select, games, and sports.

In the field called hobbies, it stores "games, sports,"

THnx for the reply,
Lothop
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 11-25-2004, 09:40 PM
vivekar's Avatar
Webmaster Talker

Posts: 539
your _POST vars can hold the select box values if you use the name as myname[] ( i.e. like an array).

You then explode the array and store it on the field.

One thing. When you refill the form using the field data, you will have some trouble.
__________________
| Submit URL at All the Websites Directory
| Get Certified in Web Design
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 11-26-2004, 01:29 AM
lothop's Avatar
Ultra Talker

Posts: 269
I understand the basis off it, just wondering how to impletement it.

EG. Storing the multiple variables in the field.

I just reinstalled windows, so i'll post my code ASAP.

PHP Code:
if ($this->sql->Update("UPDATE ".$this->TABLES['users']." SET info = '".$city."', '".$country."'  WHERE username = '".$_COOKIE['usernamecookie']."'")) {} 
Is using UPDATE wrong?
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop : 11-26-2004 at 01:35 AM.
lothop is offline
Reply With Quote
View Public Profile
 
Old 11-26-2004, 10:13 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Lothop,

I'm not sure what you need from here. You are using the concatenation method of storing values and that is a valid approach. Is it not working for you? Can you provide specifics as to what your problem is now?
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 11-26-2004, 09:15 PM
vivekar's Avatar
Webmaster Talker

Posts: 539
Hi lothop,

I think I asked you before.

I do not know what this is.
Quote:
$this->sql->Update....
What package are you using?
Your coding style is very very different. Since you are using classes you must be very very proficient with it.

Please explain.

On the other hand, we try to give you quick fixes alone, which is not what you want.
__________________
| Submit URL at All the Websites Directory
| Get Certified in Web Design
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Reply     « Reply to Adding radio button fields to database..
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14762 seconds with 12 queries