Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives

Reply
 
Thread Tools
vote/rate add-on query Details »»
vote/rate add-on query
Version: , by sabret00the sabret00the is offline
Developer Last Online: Apr 2010 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 11-28-2003 Last Update: Never Installs: 0
 
No support by the author.

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)
and then just join that to the other table via left joins?

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 11-29-2003, 11:14 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 (isset'confess_rate' && $rate && $confessionid != '' && $bbuserinfo[userid] > 0) {

  
$flood $DB_site->query("SELECT timestamp FROM confessions ORDER BY timestamp DESC LIMIT 1");
  
$check $DB_site->fetch_array($flood);

  if ((
time() - $check[timestamp]) <= 10) {
   eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
 }
  if (
$bbuserinfo[userid] == $DB_site->query("SELECT userid FROM confession_rate WHERE confessionid = $confessionid")) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
  } else {
   
$DB_site->query("INSERT INTO confession_rate SET
   confessionid = '
$confessionid',
   userid = '
$bbuserinfo[userid]',
   rate = '
$rate',
   timestamp = '"
.time ()."'");
  }
  
header("Location: $PHP_SELF?s=");
 } else {
  
header("Location: $PHP_SELF?s=");
 } 
but it won't submit to the database, what am i doing wrong?
Reply With Quote
  #13  
Old 11-29-2003, 11:18 AM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you're implenting this into vB, you'd want to do something like:
PHP Code:
####### display form #######
if (!isset($_POST['process']) or $_POST['process'] == '')
{
//display vb and form stuff
}
 
// ###### start insert ######
if (isset($_POST['process']) and $_POST['process'] != '' and $_POST['process'] == 'go')
{
//vb stuff and insert into DB stuff

Not sure if that'll be a great deal of help, used it from my mailing list hack
Reply With Quote
  #14  
Old 11-29-2003, 11:37 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry assassin, that was experimental code, heres what i was doing properly
PHP Code:
 case "voting":
// this conditional handles the rating
if ('confess_rate' && $rate && $confessionid != '' && $bbuserinfo[userid] > 0) {
$flood $DB_site->query("SELECT timestamp FROM confessions ORDER BY timestamp DESC LIMIT 1");
$check $DB_site->fetch_array($flood);
if ((
time() - $check[timestamp]) <= 10) {
eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
}
if (
$bbuserinfo[userid] == $DB_site->query("SELECT userid FROM confession_rate WHERE confessionid = $confessionid")) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
} else {
$DB_site->query("INSERT INTO confession_rate SET
confessionid = '
$confessionid',
userid = '
$bbuserinfo[userid]',
rate = '
$rate',
timestamp = '"
.time ()."'");
}
header("Location: $PHP_SELF?s=");
} else {
header("Location: $PHP_SELF?s=");
}
    break; 
but i'll try the using the super globals

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
Reply With Quote
  #15  
Old 11-29-2003, 01:32 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HTML Code:
<form method="post" name="confess_rate" action="?do=voting">
<input type="hidden" name="$confessionid">
<input type="hidden" name="$bbusername">
<table width="80%">
  <tr>
	<td align="center" colspan="2" nowrap>
	  <smallfont>rate how good you think this confession is</smallfont><br />
	  <input type="radio" name="rate" value="1" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="2" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="3" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="4" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="5" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="6" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="7" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="8" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="9" onclick="document.confess_rate.submit()">
	  <input type="radio" name="rate" value="10"onclick="document.confess_rate.submit()">
	</td>
  </tr>
  <tr>
	<td align="left" width="50%"><smallfont>Saint</smallfont></td>
	<td align="right" width="50%"><smallfont>Sinner</smallfont></td>
  </tr>
  <tr>
	<td align="center" colspan="2"><br>
	  <smallfont>this confession currently has a rating of $confession_avg_rate</smallfont>
	</td>
  </tr>
</table>
</form>
is the form that submits the data
Reply With Quote
  #16  
Old 11-29-2003, 07:30 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #17  
Old 11-29-2003, 07:33 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by sabret00the
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
hehe, nothing like food the make you think

Hope it goes ok.
Reply With Quote
  #18  
Old 11-29-2003, 10:17 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
  // this conditional handles the rating
  
if ($_POST['submit'] == 'confess_rate') {
   
$confessionid intval($_POST['confessionid']);
   
$verify $DB_site->query_first("SELECT userid FROM confession_rate WHERE confessionid = $confessionid AND userid = $bbuserinfo[userid]");
   if (
$verify) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
   } else {
    
$DB_site->query("INSERT INTO confession_rate SET
    confessionid = '
$confessionid',
    userid = '
$bbuserinfo[userid]',
    rate = '
$rate',
    timestamp = '"
.time ()."'");
 
    
header("Location: $PHP_SELF?s="); //takes you back to main confession page
   
}
  } else {
   eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
  } 
Reply With Quote
  #19  
Old 11-29-2003, 10:27 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*takes time away from his new hack*

Try using:
PHP Code:
if($action=="displayform")
{
// form code here
}
if (
$HTTP_POST_VARS['action']=="processform")
{
// queries and stuff

Then for the form tag, you would use something like
Code:
<form action="pagehere.php" method="post"><input type="hidden" name="s" value="$session[dbsessionhash]">
<!-- form code -->
 <input type="hidden" name="action" value="processform">
 <input type="submit" class="bginput" name="Submit" value="Submit Tutorial" accesskey="s">

</form>
You'll need to edit that a bit but thats a better way of doing from what i said earlier

Also, use the standardredirect function instead of header("locaion:");
Reply With Quote
  #20  
Old 11-30-2003, 11:47 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
  if ($_POST['submit'] == "rate") {
   
$confessionid intval($_POST['confessionid']);
   
$verify $DB_site->query_first("SELECT userid FROM confession_rate WHERE confessionid = $confessionid AND userid = $bbuserinfo[userid]");
   if (
$verify) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
   } else {
    
$DB_site->query("INSERT INTO confession_rate SET
    confessionid = '
$confessionid',
    userid = '
$bbuserinfo[userid]',
    rate = '
$rate',
    timestamp = '"
.time ()."'");
 
    
header("Location: $PHP_SELF?s="); //takes you back to main confession page
   
}
  } else {
   eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
  } 
arghhh, i think i just found it, i tried to pass the username with the form and not the userid will check it now
Reply With Quote
  #21  
Old 11-30-2003, 12:00 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

edit, it was such a stupid mistake
HTML Code:
<input type="hidden" name="$confessionid">
<input type="hidden" name="$bbusername">
should have been
HTML Code:
<input type="hidden" name="confessionid" value="$confessionid">
<input type="hidden" name="userid" value="$bbuserinfo[userid]">
:lol: it's still not working yet, but i'm a step closer
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:51 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04681 seconds
  • Memory Usage 2,352KB
  • Queries Executed 27 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (3)bbcode_html
  • (6)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete