can any one plz tell me how to give rating for image
Suneetha Reddy 0 Newbie Poster
Shanti C 106 Posting Virtuoso
hey suneee....
Can you clearly explain your thread?its better...
other wise nobody will reply you...
Shanti C 106 Posting Virtuoso
This is one type of rating...
If you like it...use this attachment...
This attachment is potentially unsafe to open. It may be an executable that is capable of making changes to your file system, or it may require specific software to open. Use caution and only open this attachment if you are comfortable working with zip files.
Shanti C 106 Posting Virtuoso
hey sunee...
check this url..
this may help u...
http://kevinsmithdesigns.com/blog/2008/03/04/simple-5-star-rating-system-phpmysql/
Shanti C 106 Posting Virtuoso
sunee..
plz go through this attachment...
<?
mysql_connect('localhost','root','1234');
mysql_select_db('mydb');
if($_SERVER['REQUEST_METHOD']=='POST')
{
echo $_POST['rate'];
$t="insert into vote_table(`rate`,`status`) values('".$_POST['rate']."','1')";
$r=mysql_query($t);
$msg="Thank you for your vote...";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="form1" action="" method="post">
<table width="70%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td bgcolor="#CC0099"><table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td>Please rate it : </td>
</tr>
<tr>
<td>How is this Gift Artical... </td>
</tr>
<tr>
<td align="center"><? if(!empty($msg))echo $msg;?></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="images/stillimage-medium.gif" border="1" /></td>
</tr>
<tr>
<td bgcolor="#CC0099"></td>
</tr>
<tr>
<td align="center">Your Rate:
<div align="center">
1
<input name="rate" type="radio" value="1" />
2
<input name="rate" type="radio" value="2" />
3
<input name="rate" type="radio" value="3" />
4
<input name="rate" type="radio" value="4" />
5
<input name="rate" type="radio" value="5" />
</div></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Rate!!" /></td>
</tr>
<tr>
<td align="center"><label></label></td>
</tr>
<tr>
<td bgcolor="#CC0099"></td>
</tr>
<tr>
<td align="center">Rating Results: </td>
</tr>
<tr>
<td align="center">
<?
$y="select rate from vote_table where status=1 and rate=1;";
$p=mysql_query($y);
$n=mysql_num_rows($p);
$a=0;
while($row=mysql_fetch_assoc($p))
{
$i=$row['rate'];
$a=$a+$i;
}
$avg=$a/100;
$r=$avg*100;
?>
1 ->
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0033" width="<?=$r?>"> </td>
<td > </td>
</tr>
</table>
<?
$y2="select rate from vote_table where status=1 and rate=2";
$p2=mysql_query($y2);
$n2=mysql_num_rows($p2);
$a2=0;
while($row2=mysql_fetch_assoc($p2))
{
$i2=$row2['rate'];
$a2=$a2+$i2;
}
$avg2=$a2/100;
$r2=$avg2*100;
?>
2 ->
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0033" width="<?=$r2?>"> </td>
<td > </td>
</tr>
</table>
<?
$y3="select rate from vote_table where status=1 and rate=3";
$p3=mysql_query($y3);
$n3=mysql_num_rows($p3);
$a3=0;
while($row3=mysql_fetch_assoc($p3))
{
$i3=$row['rate'];
$a3=$a3+$i3;
}
$avg3=$a3/100;
$r3=$avg3*100;
?>
3 ->
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0033" width="<?=$r3?>"> </td>
<td > </td>
</tr>
</table>
<?
$y4="select rate from vote_table where status=1 and rate=4";
$p4=mysql_query($y4);
$n4=mysql_num_rows($p4);
$a4=0;
while($row4=mysql_fetch_assoc($p4))
{
$i4=$row4['rate'];
$a4=$a4+$i4;
}
$avg4=$a4/100;
$r4=$avg4*100;
?>
4 ->
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0033" width="<?=$r4?>"> </td>
<td > </td>
</tr>
</table>
<?
$y5="select rate from vote_table where status=1 and rate=5";
$p5=mysql_query($y5);
$n5=mysql_num_rows($p5);
$a5=0;
while($row5=mysql_fetch_assoc($p5))
{
$i5=$row5['rate'];
$a5=$a5+$i5;
}
$avg5=$a5/100;
$r5=$avg5*100;
?>
5->
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0033" width="<?=$r5?>"> </td>
<td > </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.