Foros del Web » Programando para Internet » PHP »

pasar datos entre bd

Estas en el tema de pasar datos entre bd en el foro de PHP en Foros del Web. tengo un formulario que registra a los miembros de un equipo de futbol que anteriormente su capitan registro con un nombre xxa para yo poder ...
  #1 (permalink)  
Antiguo 20/07/2007, 07:38
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
pasar datos entre bd

tengo un formulario que registra a los miembros de un equipo de futbol que anteriormente su capitan registro con un nombre xxa

para yo poder mostrarle al capitan los miembros de su equipo xxa paso por url al script por ejemplo miembros?equipo=xxa y me muestra solo a los del equipo xxa.


el tema es que el formulario de registro de miembros tiene que tomar el nombre del equipo desde una bd que se llama inscripcion y al agregar el registro se guarda el nombre del equipo en la tabla

lo que no logro hacer es que el formulario me tome lo que le estoy enviando por url o
__________________
Juan Pablo Sánchez
  #2 (permalink)  
Antiguo 20/07/2007, 07:54
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años, 1 mes
Puntos: 10
Re: pasar datos entre bd

Creo que eres el del formulario o algo así:
Muestranos como tienes tus tablas, que campos estás manejando, porque creo que lo que necesitas es relacionar tus tablas.
__________________
TolerantX
http://tolerantx.com
Linux User #385226
  #3 (permalink)  
Antiguo 20/07/2007, 08:20
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
Re: pasar datos entre bd

bueno les muestro mis tablas


CREATE TABLE `miembros` (
`id` int(11) NOT NULL,
`nombre` varchar(200) NOT NULL,
`apellido` varchar(200) NOT NULL,
`rut` varchar(200) NOT NULL,
`direccion` varchar(200) NOT NULL,
`field_11` varchar(200) NOT NULL default '01',
`nacimiento` varchar(200) NOT NULL,
`e-mail` varchar(200) NOT NULL,
`npolera` varchar(200) NOT NULL,
`fono` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `inscripciones` (
`id` int(11) NOT NULL auto_increment,
`field_1` text,
`field_2` text,
`field_3` text,
`field_4` text,
`field_5` text,
`field_6` text,
`field_7` text,
`field_8` text,
`field_9` text,
`field_10` text,
`permisos` varchar(200) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

como ven la de inscripciones tiene una que se llama field_11 al igual que en la de miembros.

field_11 es donde se guarda en nombre del equipo xxa
tengo que sacar field_11 de la de inscripciones y guardarla en field_11 de la de miembros.
__________________
Juan Pablo Sánchez
  #4 (permalink)  
Antiguo 20/07/2007, 08:27
Avatar de ferbux  
Fecha de Ingreso: mayo-2007
Ubicación: por ahí intentado ayudar
Mensajes: 823
Antigüedad: 16 años, 11 meses
Puntos: 6
Re: pasar datos entre bd

puedes poner tu código php?
__________________
"Eres grande por que caminas entre gigantes"
  #5 (permalink)  
Antiguo 20/07/2007, 12:41
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
Re: pasar datos entre bd

aqui va el codigo


<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Nombre:</td>
<td><input type="text" name="nombre" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Apellido:</td>
<td><input type="text" name="apellido" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Rut:</td>
<td><input type="text" name="rut" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Direccion:</td>
<td><input type="text" name="direccion" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Field_11:</td>
<td><input type="text" name="field_11" value="<?php echo $row_Recordset2['id']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nacimiento:</td>
<td><input type="text" name="nacimiento" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Mail:</td>
<td><input type="text" name="mail" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Npolera:</td>
<td><input type="text" name="npolera" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fono:</td>
<td><input type="text" name="fono" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
<input name="field_11" type="hidden" id="field_11" value="<?php echo $row_Recordset2['id']; ?>" />
</form>
<p>&nbsp;</p>
<?php require_once('../../../Connections/cpan2l.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO miembros (nombre, apellido, rut, direccion, field_11, nacimiento, e-mail, npolera, fono) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellido'], "text"),
GetSQLValueString($_POST['rut'], "text"),
GetSQLValueString($_POST['direccion'], "text"),
GetSQLValueString($_POST['field_11'], "text"),
GetSQLValueString($_POST['nacimiento'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['npolera'], "text"),
GetSQLValueString($_POST['fono'], "text"));

mysql_select_db($database_cpan2l, $cpan2l);
$Result1 = mysql_query($insertSQL, $cpan2l) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO miembros (nombre, apellido, rut, direccion, field_11, nacimiento, mail, npolera, fono) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellido'], "text"),
GetSQLValueString($_POST['rut'], "text"),
GetSQLValueString($_POST['direccion'], "text"),
GetSQLValueString($_POST['field_11'], "text"),
GetSQLValueString($_POST['nacimiento'], "text"),
GetSQLValueString($_POST['mail'], "text"),
GetSQLValueString($_POST['npolera'], "text"),
GetSQLValueString($_POST['fono'], "text"));

mysql_select_db($database_cpan2l, $cpan2l);
$Result1 = mysql_query($insertSQL, $cpan2l) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO miembros (nombre, apellido, rut, direccion, field_11, nacimiento, mail, npolera, fono) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellido'], "text"),
GetSQLValueString($_POST['rut'], "text"),
GetSQLValueString($_POST['direccion'], "text"),
GetSQLValueString($_POST['field_11'], "text"),
GetSQLValueString($_POST['nacimiento'], "text"),
GetSQLValueString($_POST['mail'], "text"),
GetSQLValueString($_POST['npolera'], "text"),
GetSQLValueString($_POST['fono'], "text"));

mysql_select_db($database_cpan2l, $cpan2l);
$Result1 = mysql_query($insertSQL, $cpan2l) or die(mysql_error());

$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_cpan2l, $cpan2l);
$query_Recordset1 = sprintf("SELECT nombre, apellido, rut, direccion, field_11, nacimiento, mail, npolera, fono FROM miembros WHERE id = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $cpan2l) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$colname_Recordset2 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset2 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_cpan2l, $cpan2l);
$query_Recordset2 = sprintf("SELECT * FROM inscripciones1 WHERE id = %s", $colname_Recordset2);
$Recordset2 = mysql_query($query_Recordset2, $cpan2l) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);


mysql_free_result($Recordset2);
?>
__________________
Juan Pablo Sánchez
  #6 (permalink)  
Antiguo 20/07/2007, 13:23
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años, 1 mes
Puntos: 10
Re: pasar datos entre bd

Veamos si voy entendiendo porque ha sido al menos para mi, muy confuso.
Tienes dos tablas, una llamada inscripciones y otra llamada miembros.

En inscripciones se guarda el nombre del equipo (supongo que ya está guardado) y el id de inscripciones lo quieres copiar a field_11 de la tabla miembros (para que esté relacionado)?
__________________
TolerantX
http://tolerantx.com
Linux User #385226
  #7 (permalink)  
Antiguo 20/07/2007, 13:58
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
Re: pasar datos entre bd

basicamente si pero enves del id es el nombre del equipo
__________________
Juan Pablo Sánchez
  #8 (permalink)  
Antiguo 20/07/2007, 14:08
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años, 1 mes
Puntos: 10
Re: pasar datos entre bd

Si ya tienes el nombre del equipo en una tabla seria mejor no duplicar datos y enviar solo el id, ya con el join recuperarás el nombre del equipo.

Otra cosa, las dos consultas que tienes las haces con el mismo id?? Creo que tienes mal diseñadas tus tablas.
__________________
TolerantX
http://tolerantx.com
Linux User #385226

Última edición por TolerantX; 20/07/2007 a las 14:14
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 21:52.