aljaud Posted June 19, 2007 Share Posted June 19, 2007 Well, I'm very new to PHP and I'm making a script for a small vBulletin addon, and having some trouble with understanding how to do this. This is the code in the vB template when you click it. onClick="return Rate_It( '2', '$session[sessionurl]$post[userid]', '$postid' );" Here's the PHP line of code of what I have so far. $query = "INSERT INTO rate_it_bp VALUES ('','$session[sessionurl]$post[userid]','$postid')"; Here is what I'm mainly confused with. onClick="return whatdoiputhere( '2', '$session[sessionurl]$post[userid]', '$postid' );" Can anyone help? What do I put there after return, and would the $query line work how it is? Again sorry if this is a pretty noob question, I'm very new to PHP Edit: If it helps at all, here is more detail about what I'm doing. This script is for rating posts (Funny, Agree, Unfriendly, etc..) Here is the code from the vBulletin template for rating a post. <div class="rate_it"><div class="rate_bar" style="width: 140px;" id="rb_$session[sessionurl]$post[userid]"> <div class="rate_text" style="width: 140px;" id="rbt_$session[sessionurl]$post[userid]"> </div><br /> <div class="rate_button" style="background-image: url( 'images/rate/goodidea.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Good Idea' );" onClick="return Rate_It( '2', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Good Idea" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/funny.gif' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Funny' );" onClick="return Rate_It( '3', '$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Funny" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/artistic.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Artistic' );" onClick="return Rate_It( '4', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Artistic" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/friendly.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Friendly' );" onClick="return Rate_It( '6', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Friendly" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/informative.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Informative' );" onClick="return Rate_It( '7', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Informative" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/star.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', '<font color=#A06000>Gold Star</font>' );" onClick="return Rate_It( '9', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Gold Star" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/useful.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Useful' );" onClick="return Rate_It( '10', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Useful" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/winner.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Winner' );" onClick="return Rate_It( '11', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Winner" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/zing.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'ZING!' );" onClick="return Rate_It( '12', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="ZING!" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/thanks.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Thanks' );" onClick="return Rate_It( '13', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Thanks" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/disagree.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Disagree' );" onClick="return Rate_It( '14', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Disagree" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/spelling.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Awful Spelling' );" onClick="return Rate_It( '15', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Awful Spelling" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/agree.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Agree' );" onClick="return Rate_It( '16', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Agree" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/unfriendly.png' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', 'Unfriendly' );" onClick="return Rate_It( '17', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Unfriendly" class="rate_button"></a></div> <div class="rate_button" style="background-image: url( 'images/rate/dumb.gif' ); "><a href="#" onMouseOut="RateHover( false, '$session[sessionurl]$post[userid]', '' );" onMouseOver="RateHover( true, '$session[sessionurl]$post[userid]', '<font color=purple>Dumb</font>' );" onClick="return Rate_It( '18', '$session[sessionurl]$post[userid]', '$postid' );" class="rate_button"><img src="p.gif" width=16 height=16 alt="Dumb and Stupid" class="rate_button"></a></div> </div> I want a PHP script to insert that data into a Database, so I can display the ratings out of the Database (Show what that post was rated, funny/unfriendly etc..), and here is what I have so far, Un-Finished. <?php //MySQL Information $username="username"; $password="password"; $dbname="database"; //Connect to database mysql_connect(localhost,$username,$password); @mysql_select_db($dbname) or die( "Unable to connect to database"); $query = "INSERT INTO rate_it_bp VALUES ('','$session[sessionurl]$post[userid]','$postid')"; echo "Post Rated! (Not really fixing script.)\n"; //=D =D =D =D =D =D =D //=D Display ratings =D //=D =D =D =D =D =D =D //Unfinished mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/56231-help-with-inputting-onclickreturn-rate_it-values-to-database/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.