bueno despues de un buen almuerzo

(y el reposo de mi licencia)

logré hacer algo en este rato.
El_Metallick pon atencion y ve los campos que agrege en la tabla, mi tabla era de productos y agrege dos campos votos y total_votos
aqui va el codigo
valoracion.asp
archivo el cual te indica el valor de votos y tiene el link para valorarlo yo lo coloque como include en la pagina de detalles del producto
Código:
<%
'Mostramos en forma grafica los votos que el producto tiene
SQL="SELECT votos, total_votos FROM pcm_productos Where id_prod = "&Rs("id_prod")&""
Set Rsv = Server.CreateObject("ADODB.Recordset")
Rsv.Open SQL, oConn,3,1
rate = Cint(Rsv("total_votos"))/Cint(Rsv("votos"))
rate = Round(rate)
Response.Write ("Este producto ha recibido "&Rsv("votos")&" votos ")
Response.Write ("<img src=""/v1/images/"&rate&"_star_rating.gif"" width=""66"" height=""14"" alt="""&rate&" Estrellas"" border=""0"" align=""absmiddle"">")
Response.Write (" - ")
Response.Write ("<a href=""JavaScript:openWin('valoracion_producto.asp?prodID=" & rs("id_prod") & "','rate_site')"" style=""font-size:""11px""; font-style: italic;"">votar</>")
Rsv.close
set Rsv = nothing
%>
valoracion_producto.asp
esta te muestra la tabla de estrellas para que valores el producto y te verifica si ya votaste por el mismo dandote un mensaje
Código:
<%
prodID = Request.Querystring("prodID")
valoracion = Request.Cookies("valoracion")("prodID")
%>
<script language="JavaScript">
function Rating(star) {
if (star != "") self.location.href = "add_valoracion.asp?prodID=<%=prodID%>&Votos=" + star;
return true;
}
// -->
</script>
<link href="default.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<%
If valoracion = prodID Then
%>
<br>
<br>
<br>
<br>
<table width="215" height="22" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" height="140" border="0" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td class="text"><div align="center">Disculpa, pero tú ya has votado por este producto. Intenta la proxima semana <br>
<a href="JavaScript:onClick=window.close()"><br>
<br>
Cerrar Ventana </a><br>
</div></td>
</tr>
</table></td>
</tr>
</table>
<%else%>
<br>
<span class="text2">Valoración de Productos<br>
</span>Haz click en las estrellas que crees que<br>
representan el valor de votos para el<br>
producto elegido.<br>
<br>
<br>
<table width="215" height="22" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="4" bgcolor="#FFFFFF">
<tr>
<td width="50" class="text"><a href="JavaScript:Rating('0')"><img src="images/0_star_rating.gif" width="66" height="14" alt="0 Stars" border="0"></a></td>
<td width="154" class="text">No lo compraría</td>
</tr>
<tr>
<td width="50" class="text"><a href="JavaScript:Rating('1')"><img src="images/1_star_rating.gif" width="66" height="14" alt="1 Star" border="0"></a></td>
<td width="154" class="text">Solo lo vería </td>
</tr>
<tr>
<td width="50" class="text"><a href="JavaScript:Rating('2')"><img src="images/2_star_rating.gif" width="66" height="14" alt="2 Stars" border="0"></a></td>
<td width="154" class="text">Algo tiene de bueno </td>
</tr>
<tr>
<td width="50" class="text"><a href="JavaScript:Rating('3')"><img src="images/3_star_rating.gif" alt="3 Stars" width="66" height="14" border="0" align="absmiddle"></a></td>
<td width="154" class="text">OK</td>
</tr>
<tr>
<td width="50" class="text"><a href="JavaScript:Rating('4')"><img src="images/4_star_rating.gif" width="66" height="14" alt="4 Stars" border="0"></a></td>
<td width="154" class="text">Excelente</td>
</tr>
<tr>
<td width="50" class="text"><a href="JavaScript:Rating('5')"><img src="images/5_star_rating.gif" width="66" height="14" alt="5 Stars" border="0"></a></td>
<td width="154" class="text">No puede faltar en el PC </td>
</tr>
</table></td>
</tr>
</table>
<%End if%>
</div>
add_valoracion.asp
aqui traes los valores para sumar los votos nuevos y haces el UPDATE
Código:
<link href="default.css" rel="stylesheet" type="text/css">
<!--#include file="includes/conexion_sql_mod.asp" -->
<%
'Recupero el valor del voto y el valor del ID del producto
prodID = Request.Querystring("prodID")
votos = Request.Querystring("Votos")
'Traigo los votos actuales que tiene el producto para sumarle los nuevos
SQL="SELECT * FROM pcm_productos WHERE id_prod = '"&prodID&"' "
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open SQL, oConn,3,1
vact = Cint(Rs("total_votos"))
total = vact + Votos
'Sumamos uno a las votaciones
rating = Cint(Rs("votos"))+1
'Ahora que tengo el total que es lo que recibi de la base mas los votos nuevos actualizo la valoracion del producto segun su ID
SQL = "UPDATE pcm_productos Set total_votos = '"&total&"', votos = '"&rating&"' WHERE id_prod = '"&prodID&"' "
Set RS = oConn.Execute(SQL)
'Creamos una cookie con el id del producto para que no voten mas de una vez(puro grupo) le damos una semana
Response.Cookies("valoracion")("prodID")= prodID
Response.Cookies("valoracion").Expires = Now() + 7
%>
<br>
<br>
<br>
<br>
<table width="215" height="22" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" height="140" border="0" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td class="text"><div align="center"><img src="http://www.pcmod.cl/images/index01.jpg" width="200" height="60"><br>
Gracias por tu Voto<br>
<a href="JavaScript:onClick=window.close()"><br>
Cerrar Ventana </a><br>
</div></td>
</tr>
</table></td>
</tr>
</table>
ahora lo subo de una a mi sitio para valorar los productos suerte cualquier cosa no dudes en consultar.
Espero te sirva
Servirá para las FAQ's?
Chaoooo