12-21-2007, 02:31 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
(HELP!!!!!!!!) Creating a 1 - 5 Star rating script
For now I just made it say Rating Successful and Unsuccessful, and query.
PHP Code:
<style type="text/css"> input.ratingsnstuff { background:url('rate/default.png') no-repeat; border:none; width:16px; height:16px; margin:1px; cursor: pointer; } input:hover.ratingsnstuff { background:url('rate/default_hover.png') no-repeat; border:none; width:16px; height:16px; margin:1px; cursor: pointer; } </style> <form class="ratingsnstuff" action="rating.php" method="post"> <input class="ratingsnstuff" name="star1" type="button" value=""> <input class="ratingsnstuff" name="star2" type="button" value=""> <input class="ratingsnstuff" name="star3" type="button" value=""> <input class="ratingsnstuff" name="star4" type="button" value=""> <input class="ratingsnstuff" name="star5" type="button" value=""> </form> <?php
$dbhost = "localhost"; $dbuser = "root"; $dbpass = ""; $database = "rates";
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($database) or die(mysql_error());
function ratingInsert($ratings) { $rateid = intval($_REQUEST['rateid']); $rating = array($_POST['star1'], $_POST['star2'],$_POST['star3'], $_POST['star4'], $_POST['star5']); foreach($rating as $ratings) { $query = mysql_query("Insert into db_ratings WHERE rateid=".$rateid." and rate=".$ratings."");
if($query!=null) { echo "Rated successfully!"; } elseif(!$query) { echo 'Rated Unsuccessfully!'; } } }
$ratingInsert = ratingInsert($ratings); return $ratingInsert;
?>
This outputted:
Code:
Rated Unsuccessfully!Rated Unsuccessfully!Rated Unsuccessfully!Rated Unsuccessfully!Rated Unsuccessfully!
Please help!
UPDATE!!!!
Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE rateid=0 and rate=' at line 1
No idea what this means :[
|
|
|
|