好的,我有一个脚本可以在您每次评分时更改图像,并且效果很好,但问题是人们可以向评分系统发送垃圾邮件,所以我认为可以在包含 div 之前进行某种延迟设置新图像后显示评分
应该延迟的评级栏代码:
<div id="button" onclick="changeSrc2()">
<div class="rate_widget" id="<? echo $id;?>">
<div class="star_1 ratings_stars"></div>
<div class="star_2 ratings_stars"></div>
<div class="star_3 ratings_stars"></div>
<div class="star_4 ratings_stars"></div>
<div class="star_5 ratings_stars"></div>
<div class="total_votes">vote data</div>
</div>
</div>
在评分栏上单击更改图像的代码:
$number="1";
$wrongnumber="2";
$random = mysql_query("SELECT * FROM images ORDER BY RAND()");
$place="upload/";
echo '<script type="text/javascript"> ';
while($wor = mysql_fetch_array($random))
{
$ids=$wor['id'];
$name = $wor['name'];
$images = $place . $wor['name'];
$number=$number + 1;
$wrongnumber=$wrongnumber + 1;
echo 'function ' . 'changeSrc' . $number . '() '; ?>
{
document.getElementById("rand").src="<? echo $images;?>";
document.getElementById("button").onclick=changeSrc<? echo $wrongnumber;?>;
document.getElementsByClassName('rate_widget')[0].id = <? echo $ids;?>;
}
<?
}
?>
</script>
和显示第一张图片的代码:
/*Display images*/
$r = mysql_query("SELECT * FROM images ORDER BY RAND() LIMIT 1");
while($wor = mysql_fetch_array($r))
{
$place="upload/";
$id=$wor['id'];
$name = $wor['name'];
$image = $place . $wor['name'];
echo '<img id="rand" src="'.$image.'" style="max-height:330px;">';
}