![]() |
vote/rate add-on query
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) |
lol, since this morning i've dummified, so how would i go about this after i set up the tables lol
|
Moved to the correct forum :)
|
You would do something like:
PHP Code:
That's the way I did it for my vB3 point system (I think :dumbass: ) |
but wouldn't that just add or whatever to the rate was already there instead of working out an average rate?
|
Quote:
PHP Code:
|
thanks i'll try implementing this code :)
|
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. |
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.
|
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] |
thanks assassin, you've been a great help, i've got to final stages of this end of things, which means it'll be fully usable soon, all bar one thing, in my script, i'm processing the ratings via
PHP Code:
|
If you're implenting this into vB, you'd want to do something like:
PHP Code:
|
sorry assassin, that was experimental code, heres what i was doing properly
PHP Code:
ps. this is just the form processing, the actual form display elsewhere in the document. heres the link to where this is all happening http://www.ebslive.com/confessions/i...onfessionid=49 |
HTML Code:
<form method="post" name="confess_rate" action="?do=voting"> |
lol, i was standing in the kebab shop when i finally got what you meant, thanks steven, took me all day but i got there in the end, gonna try it now :)
|
Quote:
Hope it goes ok. |
got the code down from 25 lines to 17 but it's still not working, i think this is down to the actual form rather than the coding tho.
PHP Code:
|
*takes time away from his new hack*
Try using: PHP Code:
Code:
<form action="pagehere.php" method="post"><input type="hidden" name="s" value="$session[dbsessionhash]"> Also, use the standardredirect function instead of header("locaion:"); |
i'm getting so close to giving up on this, i dunno what's wrong with it, i've tried so many methods, but it's not passing to the database, infact i get the error i set up to say the vote cannot be processed :(
PHP Code:
|
edit, it was such a stupid mistake
HTML Code:
<input type="hidden" name="$confessionid"> HTML Code:
<input type="hidden" name="confessionid" value="$confessionid"> |
got it all working, special thanks to Kura, NTLDR, Assassingod, Mist and the many other who tried to help me. :)
|
All times are GMT. The time now is 01:04 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|