The Arcive of vBulletin Modifications Site. |
|
vote/rate add-on query Details »»
|
|||||||||||||||||||||||||
if i wanted to add a voting/rating process to something, how would i go about doing it?
i was thinking just set up an additional table Code:
confession id | rate | voter (bbusername) Show Your Support
|
|||||||||||||||||||||||||
| Comments |
|
#2
|
||||
|
||||
|
lol, since this morning i've dummified, so how would i go about this after i set up the tables lol
|
|
#3
|
||||
|
||||
|
Moved to the correct forum
|
|
#4
|
||||
|
||||
|
You would do something like:
PHP Code:
That's the way I did it for my vB3 point system (I think :dumbass: ) |
|
#5
|
||||
|
||||
|
but wouldn't that just add or whatever to the rate was already there instead of working out an average rate?
|
|
#6
|
||||
|
||||
|
Quote:
PHP Code:
|
|
#7
|
||||
|
||||
|
thanks i'll try implementing this code
|
|
#8
|
||||
|
||||
|
ok in setting up the table would this be right?
[sql]CREATE TABLE confession_rate ( rateid MEDIUM INT UNSIGNED NOT NULL AUTO_INCREMENT, confessionid BIGINT(20) ( SIGNED NOT NULL, userid INT(10) SIGNED NOT NULL, timestamp INT(11) NOT NULL, rate SMALLINT(2) SIGNED NOT NULL, PRIMARY KEY (rateid) );[/sql]? confessionid is set via php $confessionid user_id is set by $bbuserinfo[userid] timestamp is set when a confession is voted for rate is what you're rating the confession (1-10) and i set the primary key to by the confession id but that wouldn't work so i've decided i need another row for rateid. |
|
#9
|
||||
|
||||
|
figured out i don't need the left joins but would be great if you can tell me if i set that SIGNED and UNSIGNED stuff right.
|
|
#10
|
||||
|
||||
|
This would be a better table structure:
[SQL] CREATE TABLE confession_rate ( rateid TINYINT(5) UNSIGNED NOT NULL AUTO_INCREMENT, confessionid TINYINT(5) NOT NULL, userid TINYINT(5) NOT NULL, time TIMESTAMP(14) NOT NULL, rate SMALLINT(5) NOT NULL, PRIMARY KEY (rateid) ); [/SQL] |
![]() |
|
|