ok this isn't a complicated script or anything, but it will allow you to do what you want. I assumed it was going to be used for images, if not then you can modify the code pretty easily for it to be for something else.
first of all, you will need a file called items.inc
items.inc should look something like this...
<?php
$items['item'][0] = "item0.jpg";
$items['rating'][0] = "-1";
$items['item'][1] = "item1.jpg";
$items['rating'][1] = "-1";
$items['item'][2] = "item2.jpg";
$items['rating'][2] = "-1";
$items['item'][3] = "item3.jpg";
$items['rating'][3] = "-1";
?>
you can add or remove items by copying and pasting one of the existing sets of
$items['item'][#] = "";
$items['rating'][#] = "";
and changing the item#.jpg to the name of the image file(it doesn't have to use the item#.jpg naming convention... I just did for testing purposes) and changing the number in the [] to one greater than the current highest one (ex. if I was going to add one to that items.inc I would add
$items['item'][4] = "newpic.jpg";
$items['rating'][4] = "-1";
-you should also note that you can set the starting rating if you want. -1 is used for Unrated
-also you MUST keep them in this format of
$items['item'][#] = "";
$items['rating'][#] = "";
next, you will need a file called rateme.php
rateme.php needs to have the code:
<?php
include("items.inc");
$olditems=file("items.inc");
$line = (2 * $GET['citem']) + 2;
if ($GET['oldrating'] == "-1"){
$newrating = $GET['rating'];
}else{
$newrating = ($GET['oldrating'] + $GET['rating'])/2;
}
for ($i = 0; $i < count($olditems); $i++){
$olditems[$i] = ereg_replace("\n", "", $olditems[$i]);
$olditems[$i] = ereg_replace("\r", "", $olditems[$i]);
}
$olditems[$line] = "\$items['rating'][".$GET['citem']."] = \"$newrating\";";
$filecontents = implode("\n", $olditems);
$newfile = fopen("items.inc", "w");
fwrite($newfile, $filecontents);
fclose($newfile);
?>
Rating for <b><?php print($items['item'][$GET['citem']]); ?></b> changed from <b>
<?php
if($GET['oldrating'] == "-1"){
print("Unrated");
}else{
print($_GET['oldrating']);
}
?>
</b> to <b><?php print($newrating); ?></b>.<br>
Thank You for your Rating.
where you would like it to display "Rating for <image> changed from <oldrating> to <newrating>.
Thank You for your rating."
lastly, you need to put this code
<?php include("items.inc"); ?>
<img src="<?php
$citem = $_GET['item'];
print($items['item'][$citem]); ?>"><br>
Rating: <?php
if($items['rating'][$citem]=="-1"){
print("Unrated");
}else{
print($items['rating'][$citem]);
}
?><br>
<form action="rateme.php" method="get">
<select name="rating">
<?php
for($i = 0; $i <= 10; $i++){
print("<option value=\"$i\">$i</option>");
}
?>
</select>
<input type="hidden" name="citem" value="<?php print($citem); ?>">
<input type="hidden" name="oldrating" value="<?php print($items['rating'][$citem]); ?>">
<input type="submit" value="Rate">
</form>
where you want to display the image and its current rating and the drop down to rate it
then you must access this page using the following file index.php?item=# where index.php is the file you put the code to display the image in and # is the index number of the image you want to display (the number in the [] beside the image file in items.inc)