General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 23rd, 2003, 09:46 PM
guitarnoise guitarnoise is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 32 guitarnoise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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

Reply With Quote
  #2  
Old February 23rd, 2003, 11:00 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
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

Reply With Quote
  #3  
Old February 24th, 2003, 07:17 AM
guitarnoise guitarnoise is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 32 guitarnoise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Ok, I'll give that a try.

But I think you meant

name="radiobutton" not check box. Right?

Reply With Quote
  #4  
Old February 24th, 2003, 09:29 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
yes I am sorry,....radio

EDIT: errr,....no,.....type="radiobutton" not name

Reply With Quote
  #5  
Old February 24th, 2003, 09:54 AM
guitarnoise guitarnoise is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 32 guitarnoise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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?

Reply With Quote
  #6  
Old February 24th, 2003, 02:29 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
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?

Reply With Quote
  #7  
Old February 25th, 2003, 10:03 AM
guitarnoise guitarnoise is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 32 guitarnoise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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.

Reply With Quote
  #8  
Old February 25th, 2003, 12:09 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
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:
if($recieve_email == 'Y') { echo "selected=selected"; } 


in my database I make that field an enum works for me

glad I could help

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Using radio buttons in a content management system


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT