Foros del Web » Programando para Internet » PHP »

Checkbox en php y mysql

Estas en el tema de Checkbox en php y mysql en el foro de PHP en Foros del Web. Buenas por favor Ayuda !! no se como insertar y mostrar desde un checkbox. Muestro todo lo que tengo hasta el momento: (me funciona todo ...
  #1 (permalink)  
Antiguo 27/09/2010, 06:41
 
Fecha de Ingreso: septiembre-2010
Mensajes: 2
Antigüedad: 13 años, 6 meses
Puntos: 0
Checkbox en php y mysql

Buenas por favor Ayuda !! no se como insertar y mostrar desde un checkbox.
Muestro todo lo que tengo hasta el momento: (me funciona todo bien lo que no doy en la tecla es el checkbox ni insertar ni mostrarlo desde mysql).
Si alguien puede ayudarme Muchas Gracias de antemano.

<?
include('../auth.php');
if($_POST['submit']){
$today = date('y-m-d');
$nombre = $_POST['nombre'];
$direccion = $_POST['direccion'];
$email = $_POST['email'];
$act_principal = $_POST['act_principal'];


if ( $club_id == "" )
{
$sql = "insert into clubes (club_date, nombre, direccion, email, act_principal) values ";
$sql .= "('$today', '$nombre', '$direccion', '$email', '$act_principal')";

}
else
{
$sql = "update clubes set nombre = '$nombre', direccion = '$direccion', email = '$email', act_principal = '$act_principal', ";
$sql .= "club_id = $club_id";

}

mysql_query($sql);

header('Location: clubes.php');
exit();

}elseif($_POST['cancel']){
header('Location: clubes.php');
exit();
}else{
$club_id = $_GET['club_id'];

if ( $club_id != "" )
{
$row = mysql_fetch_array(mysql_query("select * from clubes where club_id = $club_id"));
$club_date = $row['club_date'];

$club_id = $row['club_id'];
$crow = mysql_fetch_array(mysql_query("select nombre from clubes where club_id = '$club_id'"));
$nombre = $crow['nombre'];

$status_id = $row['status_id'];
$srow = mysql_fetch_array(mysql_query("select status_desc from club_status where status_id = $status_id"));
$status_desc = $srow['status_desc'];


}
}


?>

<html>
<head>
</head>
<body><center>
<table bgcolor="#FFFFFF" width="95%">
<tr>
<td align="left">
<form name="formulario" method="post" action="seleccionar.php">
<table width="100%" border="0">
<tr>
<td>
<table>
<tr>
<td align="right">Fecha de Alta:&nbsp;</td><td align="left"><? echo date('d/m/Y', strtotime($club_date)); ?></td>
</tr>

<table bgcolor="#FFFFFF" width="100%">
<tr>
<td align="left">
<table border="0">
<tr>
<td align="right">Nombre:&nbsp;</td><td align="left"><input type="text" name="nombre" size="35" class=campo_oblig value="<? echo $row['nombre']; ?>"></td><tr>
</td>
</tr>

<tr>
<td align="right">Dirección:&nbsp;</td><td align="left"><input type="text" name="direccion" size="30" class=campo value="<? echo $row['direccion']; ?>"></td>
<tr>
<td align="right">E-mail: </td><td align="left"><input type="text" name="email" size="30" class=campo value="<? echo $row['email']; ?>">
</td>

<tr>
<td><input name="act_principal[]" type="checkbox" value="Becas">Becas</td>
<td><input name="act_principal[]" type="checkbox" value="Donaciones">Donaciones</td>
</tr>

</table>
<tr>
<td><input type="hidden" name="club_id" value="<? echo $club_id; ?>"></td>
</tr>

<input type="submit" name="submit" class="campo_boton" value="Guardar">&nbsp;&nbsp;
<button class=campo_boton onClick="window.location='clubes.php'">Cancel</button>

</td>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
  #2 (permalink)  
Antiguo 27/09/2010, 08:41
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Tema movido desde PHP orientado a objetos a PHP
  #3 (permalink)  
Antiguo 27/09/2010, 09:05
Avatar de lisandro Arg  
Fecha de Ingreso: octubre-2003
Ubicación: Cordoba, Argentina
Mensajes: 945
Antigüedad: 20 años, 6 meses
Puntos: 24
Respuesta: Checkbox en php y mysql

act_principal es una array(), podrías usar serialize() para guardalo en la base de datos y unserialize() para cuando tengas que leerlo

http://www.php.net/manual/es/function.serialize.php
http://www.php.net/manual/es/function.unserialize.php

Etiquetas: checkbox, mysql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:13.