![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
26/09/2009, 11:35
|
| | Fecha de Ingreso: septiembre-2009
Mensajes: 12
Antigüedad: 15 años, 4 meses Puntos: 0 | |
Respuesta: Como consultar dos campos en una misma tabla Amigo gjx2 el código que me envió con los cambios me arroja el siguiente error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%36%'' at line 1
código:
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table width="346" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><div align="center"><strong>CONSUTAR</strong></div></td>
</tr>
<tr>
<td width="190">NOMBRE</td>
<td width="156"><input name="nombre" type="text" id="nombre" /></td>
</tr>
<tr>
<td colspan="2">edas
<input name="edad" type="text" id="edad" size="10" maxlength="10" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="Consutar" /></td>
</tr>
</table>
</form>
<?php
if (isset($_POST['nombre']) and isset($_POST['edad'])){
include "conexion.php";
$sql = "SELECT * FROM datos WHERE nombre like '%$_POST[nombre]%' and like '%$_POST[edad]%'";
$consulta = mysql_query($sql,$conexion)or die(mysql_error());
if(mysql_num_rows($consulta)){
?>
<table width="600" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">CEDULA</div></td>
<td><div align="center">NOMBRE</div></td>
<td><div align="center">EDAD</div></td>
<td><div align="center">TELÉFONOS</div></td>
<td><div align="center">DIRECCI'ON</div></td>
</tr>
<?php
while($field = mysql_fetch_array($consulta))
{
?>
<tr>
<td><?php echo $field["ci"];?></td>
<td><?php echo $field["nombre"];?></td>
<td><?php echo $field["edad"];?></td>
<td><?php echo $field["telefonos"];?></td>
<td><?php echo $field["direccion"];?></td>
</tr>
<?php
}
?>
</table>
<?php
}
else{
echo "<b>0</b> datos encontrados";
}
}
?> |