Help with checbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Help with checbox

Post by tsalmeida »

Hi guys

I have a website with product evaluation with positive and negative points in checkbox. The points are the same.

must do the following:

The User selects the positive "durability" however after scoring the User decides "durability" as a negative point. need, when selecting the negative field the positive field is automatically cleared.

How can I do this?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Help with checbox

Post by Christopher »

Make them radio buttons instead of checkboxes.
(#10850)
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: Help with checbox

Post by tsalmeida »

hmm

how can I insert in db several radio buttons in the same column?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help with checbox

Post by Celauran »

Why would you want to do that? What are you trying to accomplish?
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: Help with checbox

Post by tsalmeida »

need to save the evaluation made ​​by each User for a particular product.

with checkbox I managed to write all correctly marked items, however if you select the same item with positive and negative will record the same way
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help with checbox

Post by Celauran »

Sounds like you might be better off using a join table (user_id, product_id, rating).
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Help with checbox

Post by Christopher »

tsalmeida wrote:need to save the evaluation made ​​by each User for a particular product.

with checkbox I managed to write all correctly marked items, however if you select the same item with positive and negative will record the same way
How you save it depends on whether/how you need to query the data later.

You can save all choices in a single record:

[text]eval_id choices
42 1,2,3,4[/text]
Or each choice as an individual record

[text]id eval_id choices
88 42 1
89 42 2
90 42 3
91 42 4[/text]
(#10850)
tsalmeida
Forum Commoner
Posts: 38
Joined: Sat Jul 06, 2013 2:23 pm

Re: Help with checbox

Post by tsalmeida »

thanks for help
Post Reply