last day (15 days later) » 

10:36 PM
0
Q: PHP '5 out of 10' Helpfulness counter question

Achmed ZuzaliI have been searching the web and stackoverflow for 60 minutes but have yet to find a solution/tutorial on here or the web explaining how I can do an 45 out of 50 helpful system in an efficient manner! Better explanation: I'm experimenting with PHP and am trying to make a helpful system i.e. '5 ...

 
@D-Shih I added my counting code at top which i'm currently using to get my desired result, i'm simply wondering if there is a better way to do it (more efficient) Thanks
 
I think it is better to create a field on the element to be voted and a field that allows the user to vote 1 time. Then it depends on what you have to do precisely. In that way you wouldn't need to count, but only to extract the value from the db
 
@Squalo thanks. What i'm trying to achieve is a Zendesk style counter where the user can say whether they found it helpful or not and just wan tto find the best way to do it as I can't find anything online! And the user can only vote once as it records their user_pin
 
@AchmedZuzali From what I understand, then you just need to add a field to the element to be voted. after which you allow the user to add +1 to that field and prohibit subsequent votes
 
@Squalo so a counter in a row where i do an update query of counter = counter + 1 ?? and then another table for the user_id and ip addresses? Thanks
 
10:36 PM
Yes, counter = counter +1. After you need to store the items voted by the users: I think it is better to enter the id of users who voted in the row of the element to be voted. Because in the future that element could be deleted
hi
 
Hi Ok and just to clarify what do you mean by...
" I think it is better to enter the id of users who voted in the row of the element to be voted. Because in the future that element could be deleted"
Thanks
 
You can put all user_id, who voted, in a field associated with the element.
 
Basically i'm trying to build this: support.zendesk.com/hc/en-us/articles/…
what as in 'user_id, user_id, user_id'?
 
the user will not have to login?
 
Maybe an example of the sql table and yes the user has to login
so no spam
 
10:40 PM
Only registered users can vote?
Ok
 
even tho i could prevent it but yes only logged in users can vote
 
Put all user_id in a field associated with element
Who voted
 
Sorry if i'm being confusing... been a long day
 
Example
i'm squalo my user_id = 12
I'm voting your post
Counter = counter +1
 
ok and then how do i store it. In rows? Separate Table? thanks
 
10:43 PM
Your elements in db have 3 fields
 
ok
id, user_id, post_id?
 
1: id
2: element
3: alluser_idwhovoted
 
ok and then do i separate it with commas ?
so 1,34,2,45,3,5,6 etc
 
of course
or ;
 
ok thankyou very much
thanks
 
10:46 PM
or whatever you want
 
great thanks again
very helpful
 
when user reopen element, you will check the ids in this field
and compare with user_id
LIMIT 1
remember LIMIT 1
ok?
 

last day (15 days later) »