Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/08/2013, 17:52
luisochonews
 
Fecha de Ingreso: agosto-2012
Mensajes: 77
Antigüedad: 11 años, 8 meses
Puntos: 0
Busqueda Error en el sistema de Likes/Dislikes

Muy buenas,
Pues aquí tengo un problemita, lo que pasa es que se muestran 3 registros en una tabla, y en cada registro se tiene la opción de darle like o dislike. El meollo del asunto es que si le doy like al primer registro, los 3 registros me pone 1 like para cada uno, si le doy like al 2do registro, el 2do y el 3er registro se van a añadir 1 like. Pero lo que yo quiero es que sólo se agregue el like al registro que estoy seleccionando. Suena muy complicado pero ojalá me entiendan, es que llevo días tratando de resolver este error.


Ejemplo, si le doy like al primer registro, los otros dos también me les pone el like (imagen de abajo), pero se supone que sólo se debe reflejar el resultado en el primero y no en el segundo ni en el tercero:


Sólo para aclarar que la subida a la base de datos está bien, el problema es al mostrar los datos, o sea en la función de Mysql de SELECT * FROM, aquí el código PHP (Ahí señalo el error):
Código PHP:
<table width="100%" bgcolor="#006699" bordercolor="#0066FF" border="3px" background="images/top3.png">
                                 <?
                 
                
if($_POST['votarl'])
                {
                    
$ip$_SERVER['REMOTE_ADDR'];
                    
mysql_query("INSERT INTO votos(alumno,votante,valor,ip) VALUES('$_POST[alumnol]','$_COOKIE[nick]','1','$ip');");
                }
                if(
$_POST['votard'])
                {
                    
$ip$_SERVER['REMOTE_ADDR'];
                    
mysql_query("INSERT INTO votos(alumno,votante,valor,ip) VALUES('$_POST[alumnod]','$_COOKIE[nick]','0','$ip');");
                }
                
                
?>
               <? 
               $row
=mysql_query("SELECT * FROM resultados ORDER BY total DESC LIMIT 3");
               while(
$row2 mysql_fetch_array($row)){ ?>
                <tr>
                <th rowspan="4" width="70px" height="70px">
                <? echo '<img src='.$row2['avatar'].' width="70px" height="70px" ice:repeating="true">'?>
                </td>
                </tr>
                <tr>
                <td colspan="3">
                <a style="color:#FFF">Alumno: <? echo ''.$row2['alumno'].''?></a>
                </td>
                </tr>
                <tr>
                <td colspan="3">
               <a style="color:#FFF">
               <? $resmysql_query("SELECT * FROM adminexamen");
                  
$numexamen=mysql_num_rows($res);
                  
$calificacionfinal=$row2['total']/$numexamen;
                
?>
               Calificación: <? echo ''.$calificacionfinal.'' ?></a>
                </td>
                </tr>
                <tr>
              
<td width="80px" height="36px">
<form name="form1" action="" method="post">
               <input type="text" hidden="" name="alumnol" value="<? echo $row2['alumno']; ?>">
 <input type="submit" name="votarl" value="    " style="background-image:url(images/like.png); background-color:#06C" width="32px" height="32px">
  </form>
                </td>
                <td width="80px" height="36px">
  <form name="form2" action="" method="post">
<input type="text"  name="alumnod" hidden="" value="<? echo $row2['alumno']; ?>">
 <input type="submit" name="votard" value="    " style="background-image:url(images/dislike.png);background-color:#06C" width="32px" height="32px">
  </form>
                </td>
                <td>
<table width="115px" border="0" cellpadding="0" cellspacing="0" bgcolor="#FF3300" style="border: #000000 1px solid;"  height:"7px">
            <tr>
              <td>
                 <? 
//Aquí la parte donde sucede el error ---->>>>>>>>>>>
                 
$bla="WHERE alumno='$row2[alumno]'";
                
$resmysql_query("SELECT * FROM votos $bla");
                while(
$res2=mysql_fetch_array($res)){
                
$numvotosmysql_num_rows($res);
                 
$totalv+=$res2['valor'];
                
$porcentaje$totalv*100/$numvotos;
                }
                
                
?>
              <table width="<? echo $porcentaje?>%" border="0" cellpadding="0" style="background:#0C3; max-width:100%" height="7px">
                  <tr>
                    <td></td>
                  </tr>
              </table></td>
            </tr>
        </table>
                </td>
                </tr>
                <?
                
echo "$totalv";
               }
                
?>
                </table>