|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using radio buttons in a content management system
I am looking for a little design help. Currently I am making a content management system using PHP and mySQL. I was wondering how to use radio buttons with such a system. I know how the html works, and I have check boxes and drop down lists in my site already. I'd like to know how to use a series of radio buttons with PHP. I'd like the buttons to reflect the information in the database and when people are updating only let them select one of many choices. I haven't seen any examples or tutorials on this. Can someone give me an idea where to start or begin on this.
Thanks a lot.
__________________
Without me my guitar is useless -- http://www.guitarnoise.com http://www.musiccareers.net |
|
#2
|
|||
|
|||
|
well,...the name="" tag will be an ID of some sorts at least thats how I do it,....like a poll ID or something,...
the value="" tag would be the selectable choices for that input field,..make sense? example,...for my poll system, Code:
<input type="checkbox" name="25" value="1" /> <input type="checkbox" name="25" value="2" /> <input type="checkbox" name="25" value="3" /> where name="25" is the poll ID and value="1, 2 and 3" are the choices make sense?
__________________
-- Jason |
|
#3
|
|||
|
|||
|
Ok, I'll give that a try.
But I think you meant name="radiobutton" not check box. Right? |
|
#4
|
|||
|
|||
|
yes I am sorry,....radio
![]() EDIT: errr,....no,.....type="radiobutton" not name ![]() |
|
#5
|
|||
|
|||
|
Thanks. I can see how this can be used to add information to the database, as in a poll.
But how can I call information from the database and have it represented in radio buttons. For example, I'm making a content management system for an online bookstore. I'd like the person using the system to be able to select one of two choices. So when the edit details page comes up I'd like the current choice to be selected, but it should also be possible for the editor to choose the other button. I'd really like to do this with radio buttons rather than a drop down list. Did I explain this clearly? |
|
#6
|
|||
|
|||
|
ohh I see,.....what you would need to do is perform a check to see if the value matchs an entry in the database,...
Code:
<input type="radiobutton" name="choice" value="yes" <?php if($db_record == "yes") echo "selected=selected"; ?> <input type="radiobutton" name="choice" value="no" <?php if($db_record == "no") echo "selected=selected"; ?> You get the idea? |
|
#7
|
|||
|
|||
|
Thanks a lot, Jason.
With your idea I was able to get done what I wanted. I didn't and still don't quite understand the selected=selected part. But I got the script to spit out CHECKED and that did the trick for me. |
|
#8
|
|||
|
|||
|
echo input type, radio, checkbox, listbox, has a selected property.
checkbox - checked=checked radio - selected=selected I use the letters Y, and N for alot of stuff that requires 1 of 2 choices. like PHP Code:
in my database I make that field an enum works for me ![]() glad I could help |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Using radio buttons in a content management system |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|