
18/03/2011, 19:42
|
| | Fecha de Ingreso: marzo-2011 Ubicación: Palmira
Mensajes: 7
Antigüedad: 14 años Puntos: 0 | |
Consulta PHP y MYSQL Hola mi duda es:
que yo hago una busqueda a la tabla provedorescon estos campos: Codigo,,,,,Apellido,,,,,DNI
y me trae como resultado: el codigo pero los demas datos no me aparecen o me aparecen en ceroel codigo es este:
<?php
$bandera = $_REQUEST["bandera"];
if ($_REQUEST["bandera"] ==1)
{
$cod_prove = $_REQUEST["cod_prove"];
$ape_prove = $_REQUEST["ape_prove"];
$doc_prove = $_REQUEST["doc_prove"];
$con= mysql_connect("localhost","root","localhost")
or die ("no se puede conectar con el servidor");
//echo "El usuario se ha conectado con el servidor localhost";
$resp= mysql_select_db("test")
or die ("<br>no se puede seleccionar la base de datos");
echo "<br>";
$sql=" select c.cod_prove,c.nom_prove,c.ape_prove,c.doc_prove,c. cuil_prove,c.dom_prove,c.tel_prove from proveedoresn as c
where c.cod_prove= " . $cod_prove;
if ($cod_prove != "")
{
$sql .= " and c.cod_prove=" . $cod_prove;
}
if ($ape_prove != "")
{
$sql .= " and c.ape_prove like '%" .trim($ape_prove) . "%' ";
}
if ($doc_prove != "")
{
$sql .= " and c.doc_prove LIKE '%" . $doc_prove . "%'";
}
// echo $sql;
$result_prove= mysql_query($sql);
}
else
{
//echo "vacio";
}
?>
<!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>Documento sin título</title>
<style type="text/css">
<!--
.Estilo1 { font-size: 24px;
color: #FFFFFF;
}
.Estilo2 { font-size: 16px;
color: #FFFFFF;
}
.Estilo3 {color: #FFFFFF}
.Estilo4 {color: #55660F}
.Estilo9 {font-size: 16px}
-->
</style>
</head>
<script>
function consultar()
{
//alert("hola");
var cod_prove= document.all.cod_prove.value;
var ape_prove = document.all.ape_prove.value;
var doc_prove = document.all.doc_prove.value;
if (cod_prove == "" && ape_prove == "" && doc_prove== "" )
{
alert("Debe completar al menos un filtro de busqueda");
return;
}
document.location.href = "formconsulta de prove.php?cod_prove=" + cod_prove + "&ape_prove=" + ape_prove + "&doc_prove=" + doc_prove + "&bandera=1";
}
</script>
<body>
<table width="1310" height="229" border="4" bordercolor="#000000">
<tr>
<th width="361" height="223" align="left" valign="top" scope="col"><img src="pinturas-botes.jpg" alt="3" width="332" height="219" /></th>
<th width="467" align="left" valign="top" scope="col"><img src="LOGO1.jpg" alt="2" width="497" height="219" /></th>
<th width="454" align="left" valign="top" scope="col"><img src="FRENTE 2.jpg" alt="1" width="454" height="219" /></th>
</tr>
</table>
<table width="1310" border="4" bordercolor="#000000">
<tr>
<td width="303" align="center" valign="middle"><img src="quienes somos.png" alt="6" width="129" height="53" /></td>
<td width="334" align="center" valign="middle"><img src="servicios.png" alt="7" width="129" height="53" /></td>
<td width="324" align="center" valign="middle"><a href="clientes principal.html"><img src="clientes.png" alt="4" width="129" height="53" border="0" /></a></td>
<td width="315" align="center" valign="middle"><img src="contactenos.png" alt="5" width="129" height="53" /></td>
</tr>
</table>
<table width="1312" border="4" bordercolor="#000000">
<tr>
<td width="1060"><img src="barra consulta de prove.jpg" width="1297" height="144" /></td>
</tr>
</table>
<table width="1001" border="0">
<tr>
<td width="123"><a href="formalta de prove.php"><img src="alta.png" alt="11" width="123" height="46" border="0" /></a><a href="formbaja de prove.php"><img src="baja.png" alt="22" width="123" height="46" border="0" /></a><a href="formeditar de prove.php"><img src="editar.png" alt="44" width="123" height="46" border="0" /></a><a href="formconsulta de prove.php"><img src="consulta.png" alt="33" width="123" height="46" border="0" /></a></td>
<td width="109"> </td>
<td width="755" rowspan="5" align="center" valign="top" bgcolor="#55660F"><fieldset>
<legend><span class="Estilo1">Formulario</span></legend>
<p> </p>
<form id="formconsulta de prove" name="forconsulta de prove" method="post" action="">
<label><span class="Estilo2">Código</span>
<input name="cod_prove" type="text" id="cod_prove" />
<span class="Estilo4"> 11111</span> </label>
<span class="Estilo3">
<label> Apellido
<input name="ape_prove" type="text" id="ape_prove" />
<span class="Estilo4"> 11111</span> </label>
</span>
<label> </label>
<label><span class="Estilo3">DNI
<input name="doc_prove" type="text" id="doc_prove" />
</span> </label>
</form>
<p>
<input name="Submit" type="button" class="Estilo9" value="Consultar" onclick="consultar()" />
<label></label>
<label>
<input name="alta de prove" type="button" class="Estilo9" value="Limpiar" onclick='limpiar()' />
</label>
</p>
<p>
<label></label>
<label></label>
<?php
if ($bandera == 1)
{
?>
</p>
</p>
<label></label>
<label></label>
<table align="center" border="2" cellpadding="1" cellspacing="1" width="93%" height="109" rowspan="1" bgcolor="#FDFDFD">
<tr align=center>
<td height="23" colspan=9><b>DATOS DEL PROVEEDOR</b></td>
</tr>
<tr>
<td width=78> <center><b>CODIGO</b></center></td>
<td width=91> <center><b>APELLIDO</b></center></td>
<td width=85> <center><b>NOMBRE</b></center></td>
<td width=106> <center><b>DOCUMENTO</b></center></td>
<td width=69> <center><b>CUIL</b></center></td>
<td width=101> <center><b>DOMICILIO</b></center></td>
<td width=101> <center><b>TELEFONO</b></center></td>
<td width="130" colspan=3> <center><b>Accion</b></center></td>
</tr>
<?PHP
//$cantidad = mysql_num_row($result_alu);
//if ($cantidad > 0)
if(mysql_num_rows($result_prove) == 0 )
{
?>
<TABLE align=center border=0 >
<TR ALIGN="CENTER">
<TD colspan="7"><b>NO SE HA ENCONTRADO REGISTROS PARA LOS FILTROS SELECCIONADOS!!!</b></TD>
</TR>
</TABLE>
<?php
}
?>
<?php
while ($row_prove = mysql_fetch_row($result_prove)) {
?>
<tr>
<td align="center"><?php echo $row_prove[0] ?></td>
<td align="center"><?php echo $row_prove[2] ?></td>
<td align="center"><?php echo $row_prove[1] ?></td>
<td align="center"><?php echo $row_prove[3] ?></td>
<td align="center"><?php echo $row_prove[5] ?></td>
<td align="center"><?php echo $row_prove[6] ?></td>
<td align="center"><?php echo $row_prove[7] ?></td>
<?php
echo "<td align=center><A href=\"actualizar prove?cod_prove=" .$row_prove[0]."\">Editar</a></td>\n";
echo "<td align=center><A href=\"baja de prove.php?cod_prove=" .$row_prove[0]."\">Eliminar</a></td>\n";
?>
</tr>
<?PHP
}
}
?>
</TABLE>
<?PHP ?>
</table>
<p> </p>
</fieldset></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="116"><a href="formeliminar de prove.php"></a></td>
<td> </td>
</tr>
</table>
</body>
</html>
Desde ya queda de mas decirlequemuchas gracias |