Foros del Web » Programando para Internet » PHP »

ayuda con juego de registros

Estas en el tema de ayuda con juego de registros en el foro de PHP en Foros del Web. hola chicos.. tengo una duda... resulta que hago un juego de registros para poder jalar datos de la base de datos y ponerlo en un ...
  #1 (permalink)  
Antiguo 31/01/2011, 13:03
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Pregunta ayuda con juego de registros

hola chicos.. tengo una duda... resulta que hago un juego de registros para poder jalar datos de la base de datos y ponerlo en un formato ya creado en dreamweaver... pero tengo llaves foraneas, por lo tanto en lugar de q me ponga la llave foranea quiero que me escriba lo que vale esa llave foranea por ejemplo:

folio: 1
unidad: 28 (quiero q me muestre Unidad 68)
nombre: 4 (quiero q me muestre Diana)

espero averme explicadooooo

plisss espero puedan ayudarme :(
__________________
ѕiεмpяε εѕтoy ѕoñαиdo *εи iиviεrиo coи εℓ ѕoℓ, coи ℓαѕ иubεѕ εи vεrαиo*
***DiαиiтHα***
  #2 (permalink)  
Antiguo 31/01/2011, 13:20
 
Fecha de Ingreso: febrero-2005
Mensajes: 187
Antigüedad: 19 años, 2 meses
Puntos: 2
Respuesta: ayuda con juego de registros

Debes hacer un Inner Join, con las tablas implicadas algo asi:

Código PHP:
<?php

$sql 
"
SELECT folios.*,  unidades.unidad, usuarios.nombre 
FROM 
folios Inner join unidades on folios.unidad = unidades.id
Inner Join usuarios on folios.nombre = usuarios.id
where
folio.id = 1
"
;
?>
__________________
___________________________
Hosting y Dominios en colombia
Blog de Cubica
  #3 (permalink)  
Antiguo 31/01/2011, 13:55
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Respuesta: ayuda con juego de registros

esa consulta la puse en el juego de registros... pero me dice que no hay datos.... quedo asi:

select reporte.*, unidades.unidad, usuarios.nombre
from reporte inner join unidades on reporte.id_unidad = unidades.id_unidad
inner join usuarios on reporte.id_nom = usuarios.id_nom
where folio = colname



colname es una variable q me crea el juego de registros:

colname = $_POST['folio']
__________________
ѕiεмpяε εѕтoy ѕoñαиdo *εи iиviεrиo coи εℓ ѕoℓ, coи ℓαѕ иubεѕ εи vεrαиo*
***DiαиiтHα***
  #4 (permalink)  
Antiguo 31/01/2011, 14:23
(Desactivado)
 
Fecha de Ingreso: enero-2011
Mensajes: 9
Antigüedad: 13 años, 3 meses
Puntos: 1
Respuesta: ayuda con juego de registros

Pues no te entendí su mostraras tu código sería mas facil sugerirte algo...

Última edición por GatorV; 10/06/2011 a las 07:57
  #5 (permalink)  
Antiguo 31/01/2011, 14:28
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Respuesta: ayuda con juego de registros

<?php require_once('Connections/informa.php'); ?>
<?php
$colname_imp1 = "-1";
if (isset($_POST['folio'])) {
$colname_imp1 = (get_magic_quotes_gpc()) ? $_POST['folio'] : addslashes($_POST['folio']);
}
mysql_select_db($database_informa, $informa);
$query_imp1 = sprintf("SELECT reporte.*, unidades.unidad, usuarios.nombre FROM reporte inner join unidades on reporte.id_unidad = unidades.id_unidad inner join usuarios on reporte.id_nom = usuarios.id_nom WHERE folio = %s", $colname_imp1);
$imp1 = mysql_query($query_imp1, $informa) or die(mysql_error());
$row_imp1 = mysql_fetch_assoc($imp1);
$totalRows_imp1 = mysql_num_rows($imp1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.::Imprimir Reporte::.</title>
<link href="imagenes/favicon.ico" rel="shortcut icon"/>
<style type="text/css">
<!--
.Estilo2 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; }
.Estilo5 {font-size: 12px}
.Estilo6 { font-size: 14px;
font-weight: bold;
}
.Estilo8 {font-size: 12px; font-family: Geneva, Arial, Helvetica, sans-serif; }
.Estilo17 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
.Estilo19 {font-size: 12px; font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; }
.Estilo23 {font-size: 12}
.Estilo24 {font-family: Geneva, Arial, Helvetica, sans-serif}
-->
</style>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" height="101" rowspan="4" scope="col"><p align="center"><img src="Imagenes/logo vivir mejor.gif" width="73" height="64" /></p></td>
<td height="18" colspan="2" scope="col"><p align="center" class="Estilo17"></p></td>
<td width="13%" rowspan="4" scope="col"><div align="center"><img src="Imagenes/IMSS-.gif" width="73" height="64" /></div></td>
</tr>
<tr>
<td height="17" colspan="2" scope="col"><div align="center"><strong><span class="Estilo2"></span></strong></div></td>
</tr>
<tr>
<td height="19" colspan="2" scope="col"><div align="center"><strong><span class="Estilo2"></span></strong></div></td>
</tr>
<tr>
<td height="35" colspan="2" scope="col"><div align="center"><strong>.:: R E P O R T E ::. </strong></div></td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="41%">&nbsp;</td>
<td colspan="2"><table width="350" border="1" align="center" cellspacing="0" bordercolor="#000000">
<tr>
<td height="19" colspan="2" scope="col"><span class="Estilo5">FOLIO: <strong><?php echo $row_imp1['folio']; ?></strong></span></td>
</tr>
<tr>
<td width="174" scope="row"><span class="Estilo5">FECHA:<strong><?php echo $row_imp1['fecha']; ?></strong></span></td>
<td width="166"><span class="Estilo5">HORA:<strong><?php echo $row_imp1['hora']; ?></strong></span></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4"><blockquote>
<p align="center">&nbsp;</p>
<p align="center"><span class="Estilo6">.::DATOS DE QUIEN REPORT&Oacute;::.</span></p>
</blockquote></td>
</tr>
<tr>
<td colspan="4"><table width="735" border="1" align="center" cellspacing="0" bordercolor="#000000">
<tr>
<td width="144" scope="row"><div align="center" class="Estilo8">UNIDAD:</div></td>
<td colspan="6" class="Estilo19"><?php echo $row_imp1['id_unidad']; ?></td>
</tr>
<tr>
<td scope="row"><div align="center"><span class="Estilo8">AREA:</span></div></td>
<td colspan="6" class="Estilo19"><?php echo $row_imp1['area']; ?></td>
</tr>
<tr>
<td scope="row"><div align="center"><span class="Estilo8">NOMBRE : </span></div></td>
<td colspan="6" class="Estilo19"><?php echo $row_imp1['reporta']; ?></td>
</tr>
<tr>
<td scope="row"><div align="center"><span class="Estilo8">TEL:</span></div></td>
<td width="124" class="Estilo19"><?php echo $row_imp1['tel']; ?></td>
<td width="97" class="Estilo19"><div align="center" class="Estilo23"><span class="Estilo24">EXT:</span></div></td>
<td width="146" class="Estilo19"><?php echo $row_imp1['ext']; ?></td>
<td colspan="2" class="Estilo19"><div align="center" class="Estilo23"><span class="Estilo24">VPN:</span></div></td>
<td width="146" class="Estilo19"><?php echo $row_imp1['vpn']; ?></td>
</tr>
</table></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4"><div align="center" class="Estilo6">
<p><strong>.::DATOS DEL EQUIPO::.</strong></p>
<p>&nbsp;</p>
</div></td>
</tr>
<tr>
<td colspan="4"><table width="735" border="1" align="center" cellspacing="0" bordercolor="#000000">

<tr>
<td width="144" scope="row"><div align="center"><span class="Estilo8">INVENTARIO:</span></div></td>
<td width="124" class="Estilo19"><?php echo $row_imp1['inventario']; ?></td>
<td width="97"><div align="center"><span class="Estilo8">SERIE:</span></div></td>
<td width="146" class="Estilo19"><?php echo $row_imp1['serie']; ?></td>
<td><div align="center"><span class="Estilo8">NUM. IP :</span></div></td>
<td width="146" class="Estilo19"><?php echo $row_imp1['ip']; ?></td>
</tr>
<tr>
<td scope="row"><div align="center"><span class="Estilo8">MARCA:</span></div></td>
<td class="Estilo19"><?php echo $row_imp1['marca']; ?></td>
<td><div align="center"><span class="Estilo8">MODELO:</span></div></td>
<td class="Estilo19"><?php echo $row_imp1['modelo']; ?></td>
<td><div align="center"><span class="Estilo8">DISPOSITIVO:</span></div></td>
<td class="Estilo19"><?php echo $row_imp1['dispositivo']; ?></td>
</tr>
<tr>
<td colspan="6" scope="row"><p class="Estilo8">DESCRIPCI&Oacute;N DE LA FALLA :</p>
<p class="Estilo19"><?php echo $row_imp1['falla']; ?></p></td>
</tr>
<tr>
<td scope="row"><span class="Estilo8">ATENDI&Oacute;:</span></td>
<td colspan="5" class="Estilo19"><?php echo $row_imp1['id_nom']; ?></td>
</tr>
<tr>
<td colspan="6" scope="row"><p class="Estilo8">ACTIVIDADES REALIZADAS :</p>
<p class="Estilo19"><?php echo $row_imp1['actividades']; ?></p></td>
</tr>
</table>
<p>&nbsp;</p></td>
</tr>
<tr>
<script language="JavaScript" type="text/javascript">

function imprime(){
//desaparece el boton
document.getElementById("btnImprimir").style.displ ay='none'
//se imprime la pagina
window.print()

}

</script>
<td height="30" colspan="4"><div align="center"><span class="Estilo5">
<input name="btnImprimir" id="btnImprimir" type="button" class="button" value="IMPRIMIR" onclick="imprime()" />
</span><a href="menu_admon.php">&lt;&lt;</a></div></td>
</tr>
</table>
<form id="form1" name="form1" method="post" action="">
</form>
</body>
</html>
<?php
mysql_free_result($imp1);
?>
__________________
ѕiεмpяε εѕтoy ѕoñαиdo *εи iиviεrиo coи εℓ ѕoℓ, coи ℓαѕ иubεѕ εи vεrαиo*
***DiαиiтHα***
  #6 (permalink)  
Antiguo 31/01/2011, 14:30
 
Fecha de Ingreso: febrero-2005
Mensajes: 187
Antigüedad: 19 años, 2 meses
Puntos: 2
Respuesta: ayuda con juego de registros

Intenta asi:

Código PHP:
$sql select reporte.*, unidades.unidadusuarios.nombre
from reporte inner join unidades on reporte
.id_unidad unidades.id_unidad
inner join usuarios on reporte
.id_nom usuarios.id_nom
where folio 
'$colname'"; 

Te falto el simbolo de dolar para la variable y ademas ponerlo entre comillas, pues es un texto.

Que error te sale en la bd?
__________________
___________________________
Hosting y Dominios en colombia
Blog de Cubica
  #7 (permalink)  
Antiguo 31/01/2011, 14:34
 
Fecha de Ingreso: agosto-2010
Mensajes: 147
Antigüedad: 13 años, 8 meses
Puntos: 1
Respuesta: ayuda con juego de registros

ahi deje el codigo q tngo.... ahi se ve q tiene $....
__________________
ѕiεмpяε εѕтoy ѕoñαиdo *εи iиviεrиo coи εℓ ѕoℓ, coи ℓαѕ иubεѕ εи vεrαиo*
***DiαиiтHα***
  #8 (permalink)  
Antiguo 31/01/2011, 14:51
 
Fecha de Ingreso: febrero-2005
Mensajes: 187
Antigüedad: 19 años, 2 meses
Puntos: 2
Respuesta: ayuda con juego de registros

porque no imprimis en pantalla el query? asi vas a darte cuenta si va todo bien, si lo ves bien luego de imprimirlo entonces copialo y lo ejecutas directamente en la bd.
__________________
___________________________
Hosting y Dominios en colombia
Blog de Cubica

Etiquetas: registros, juegos
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 04:30.