0

i need some help here.

I need to create this grid that allows the user to select a winner, and that winner will be stored into a table in my database.

Im geeting all done, until the point were i need to me this Radio Button working, it inserts an empty row.

This my form...

while($row = mysqli_fetch_array($result))
  {

  echo "<tr>";
  echo "<td>" .$row['id']."</td>";
  echo "<td>" . "<input type='radio' name='premio' value='".$row['id']."'>" ."</td>";
  echo "<td >" .$row['nombre']. "</td>";
  echo "<td name='correo'>" . $row['correo'] . "</td>";
  echo "<td name='telefono'>" . $row['telefono'] . "</td>";
  echo "<td>" . $row['ar1'] . "</td>";
  echo "<td>" . $row['ar2'] . "</td>";
  echo "<td>" . $row['br1'] . "</td>";
  echo "<td>" . $row['br2'] . "</td>";
  echo "<td>" . $row['cr1'] . "</td>";
  echo "<td>" . $row['dr1'] . "</td>";
  echo "<td>" . $row['dr2'] . "</td>";
  echo "<td>" . $row['dr3'] . "</td>";
  echo "<td>" . $row['er1'] . "</td>";
  echo "<td>" . $row['er2'] . "</td>";
  echo "</tr>";
  }
echo "</table>";


echo "<input type='submit' value='enviar'/>";

mysqli_close($con);
?>

</form>

</div>

And the link if you want to check it out.

http://www.gifted.cl/clientes/servier/registro_evento_1.php

php

<?php
$con=mysqli_connect("localhost","user","pass","db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="INSERT INTO ganadoresevento (nombre,correo,telefono)
VALUES
('$_POST[nombre]','$_POST[correo]','$_POST[telefono]')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo "Respuestas registradas";

mysqli_close($con);
?>

Thanks in advance

2
  • I don't see anything in your PHP for your radio button. Nov 25, 2013 at 15:21
  • You aren't using any <input type="radio" /> for the other fields
    – AdRock
    Nov 25, 2013 at 15:29

1 Answer 1

0
echo "<td>" . "<input type='radio' name='premio' value='".$row['id']."'>" ."</td>";
echo "<td>" . "<input type='radio' name='nombre' value='".$row['nombre']."'>" ."</td>";
echo "<td>" . "<input type='radio' name='correo' value='".$row['correo']."'>" ."</td>";
echo "<td>" . "<input type='radio' name='telefono' value='".$row['telefono']."'>" ."</td>";

Don't really know what inputs you want to use but this uses radio button. You could use <input type="text"> or <input type="hidden">

Have a look at prepared statement also http://www.php.net/manual/en/mysqli.prepare.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.