Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/05/2012, 14:42
ezebongiovi
 
Fecha de Ingreso: enero-2012
Ubicación: Buenos Aires
Mensajes: 13
Antigüedad: 12 años, 3 meses
Puntos: 0
Pregunta Sistema de puntuacion problemita

Tengo un pequeño problema.. quiero que se muestren 2 fotos, y que al darle click a una de las dos, en la base de datos.. en el campo " votos " se sume 1 al valor que tenga... Mi codigo es este:

Código PHP:
<form method="post" action="" name="form1">
<?php
$conexion
=mysql_connect("localhost","root","ascent");
mysql_select_db("facemash",$conexion);
$row=mysql_query("SELECT * from fotos");
$conteo=mysql_num_rows($row);
$id1=rand(1,$conteo); 

$registros=mysql_query("Select * from fotos where id='$id1'") or die ("Imposible to select the firstone");
if(
$datos=mysql_fetch_array($registros))

    {
      echo 
"<input type='image' name='voto1' src='facemash/".$datos[nombre].".".$datos[formato]."' width='200' height='250'>";
}

?>

</form>


</td><td width="10">Or</td><td width="200">

<?php $id2=rand(1,$conteo); 

while(
$id1==$id2){
$id2=rand(1,3);
}

$registros2=mysql_query("Select * from fotos where id='$id2'") or die ("Imposible to select the secondone");
if(
$datos2=mysql_fetch_array($registros2))
    {


      echo 
"<form method='post' action='' name='form2'><input type='image' name='voto2' src='facemash/".$datos2[nombre].".".$datos2[formato]."' width='200' height='250' onclick=".$voto2."></form>";

}

?>
Intente agregarle a esto, lo siguiente:

if(isset($_POST[form1])){
$voto1=mysql_query("update fotos set votos=$datos[votos]+1 where id=$id1");
}

Pero al darle click a la foto no sucede nada, solo cambian las fotos, pero no envia la info a la base de datos =/ donde esta el problema?