Database > MySQL database

How to insert RATING values into DB

(1/1)

pokka:
hey guys,i need some help on my code cause i am having trouble in inserting the values for rating into the database ! This is a mouse over 5star rating ,below are my codes which i have done !

completesurveyfinalized.php

<html>
<head>
<h1>Rate the provision store </h1>
<style type="text/css">
h1{text-align:center;
font-family:Arial;}
body{text-align:center;
 font-family:Arial;}
</style>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var hightlight_uri = "http://2.bp.blogspot.com/-uAqV7ZQSy-Y/TsqvvD9vUiI/AAAAAAAAAlM/nk-K6MIOcy0/s1600/gold_star-850.jpg";
var normal_uri = "http://www.enchantedlearning.com/crafts/stringofstars/startemplate.GIF";
var rating =
({
reliability:0,
efficiency:0,
service:0,
popularity:0
});

//Initialize
var star_rating = $(".star-rating");
for(var i=0;i<star_rating.length;i++)
$(star_rating).attr("src", normal_uri);

//Click handler
$(".star-rating").click(function()
{
var index = $(this).data("index");
var isValidSelection = index != rating[$(this).parent("div").data("category")];
var children = $(this).parent("div").children();
for(var i=0;i<children.length;i++)
{
if(parseInt($(children).data("index"))<=index && isValidSelection)
{
$(children).attr("src", hightlight_uri);
}
else
{
$(children).attr("src", normal_uri);
}
}
rating[$(this).parent("div").data("category")] = isValidSelection?index:0;
});
});
</script>
</head>
<body>

<SELECT>
<?php

include_once('config2.php');
//construct SQL
$sql="SELECT * FROM provision";
//send to mysql using mysqli object
$result=$mysqli->query($sql);
//iterate

while(list ($provisionid,$provisionstore)=$result->fetch_row())
echo "<option data-provisionid='".$provisionid."'>".$provisionstore."</option>";
$result->free();
$mysqli->close();
?>
</SELECT>
<p>Provision store:</p>
<p>Reliability Rating</p>
<div data-category="reliability">
<img width="40" height="40" data-index="5" class="star-rating" />
<img width="40" height="40" data-index="6" class="star-rating" />
<img width="40" height="40" data-index="7" class="star-rating" />
<img width="40" height="40" data-index="8" class="star-rating" />
</div>
<p>Efficiency Rating</p>
<div data-category="efficiency">
<img width="40" height="40" data-index="5" class="star-rating" />
<img width="40" height="40" data-index="6" class="star-rating" />
<img width="40" height="40" data-index="7" class="star-rating" />
<img width="40" height="40" data-index="8" class="star-rating" />
</div>
<p>Service Rating</p>
<div data-category="service">
<img width="40" height="40" data-index="5" class="star-rating" />
<img width="40" height="40" data-index="6" class="star-rating" />
<img width="40" height="40" data-index="7" class="star-rating" />
<img width="40" height="40" data-index="8" class="star-rating" />
</div>
<p>Popularity Rating</p>
<div data-category="popularity">
<img width="40" height="40" data-index="5" class="star-rating" />
<img width="40" height="40" data-index="6" class="star-rating" />
<img width="40" height="40" data-index="7" class="star-rating" />
<img width="40" height="40" data-index="8" class="star-rating" />
</div>
<button type=submit>Submit</button>
<button type=Cancel>Cancel</button>

</body>

</html>



Some help would be really appreciated ! Any guidance would be nice too ! :) thanks guys !

Cheers !

RaythXC:
You don't have a form anywhere in that so you're really not going to be able to submit anything.

Navigation

[0] Message Index

Go to full version