Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/07/2010, 08:59
ingpedro
 
Fecha de Ingreso: junio-2010
Ubicación: Mexico
Mensajes: 23
Antigüedad: 14 años, 9 meses
Puntos: 0
Ayuda..consultas con instrucciones sql en php

Muy buenos dias gente bonita de forosdelweb...

Estoy haciendo un sistema web de control escolar y ya casi esta todo listo.
Mi problema esta cuando hago una consulta en cualquier tabla indicando especificamente el dato a buscar, me lo busca sin ningun problema, ahora lo que quiero hacer es, que, cuando no me encuentra ningun dato que coincida con el indicado que me mande un mensaje en pantalla indicando el dato no existe..... a continuacion les pngo el codigo de consulta que utilizo para que vean y asi me puedan ayudar.. gracias a todos y Lindo dia!!!!

consultaAlumnos.php
<body>///este es mi form donde indico el dato a buscar...
<form action="recibeConsulta.php" method="post" name="formCA" onSubmit="javascript:return validaconsultaAlumnos();">
Seleccione el tipo de busqueda
<select name="menu">
<option value="seleccione">--Seleccione--</option>
<option value="Matricula">MATRICULA</option>
<option value="Nombre">NOMBRE</option>
<option value="Apat">APELLIDO</option>
</select>
<input name="txt1" type="text" />
<br>
<center><input name="boton1" type="submit" value="Consultar" /></center>
</form>
</body>

recibeConsulta.php// en esta parte es donde ejecuto mis instrucciones sql para realizar la busqueda y despues desplegarlos en una tabla...
<body>
<?php
$tipo=$_POST["menu"];
$termino=$_POST["txt1"];
include ("conectar.php");
$Link=Conectar();
$sql="select * from alumnos where $tipo like '%$termino%'";
$Resul=mysql_query($sql,$Link);
$total=mysql_num_rows($Resul);
echo"<br>Fecha de consulta ".date("l d F Y h:i A");
echo"<h3><br/><center>Alumnos actualmente registrados en el Sistema SICOELI</center></h3>";
echo"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Busqueda Filtrada por:$tipo <br/><br/>";
echo"<center>";
echo"<table width=50% border=1";
echo"<tr><b>";
echo"<td width=5%>MATRICULA</td>";
echo"<td width=30%>NOMBRE</td>";
echo"<td width=30%>APELLIDO PATERNO</td>";
echo"<td width=30%>APELLIDO MATERNO</td>";
echo"<td width=30%>FECHA NACIMIENTO</td>";
echo"<td width=30%>SEXO</td>";
echo"<td width=30%>DIRECCION</td>";
echo"<td width=30%>MAIL</td>";
echo"<td width=30%>TELEFONO</td>";
echo"<td width=30%>DOCUMENTOS ENTREGADOS</td>";
echo"<td width=30%>FECHA_ALTA</td>";
for($i=0;$i<$total;$i++)
{
$row=mysql_fetch_array($Resul);
echo"<tr>";
echo"<td width=5%>";
echo $row["Matricula"];
echo"</td>";
echo"<td width=20%>";
echo $row["Nombre"];
echo"</td>";
echo"<td width=20%>";
echo $row["Apat"];
echo"</td>";
echo"<td width=20%>";
echo $row["Amat"];
echo"</td>";
echo"<td width=20%>";
echo $row["Fecha_Na"];
echo"</td>";
echo"<td width=20%>";
echo $row["Sexo"];
echo"</td>";
echo"<td width=20%>";
echo $row["Direccion"];
echo"</td>";
echo"<td width=20%>";
echo $row["Mail"];
echo"</td>";
echo"<td width=20%>";
echo $row["Telefono"];
echo"</td>";
echo"<td width=20%>";
echo $row["Doc_Entregados"];
echo"</td>";
echo"<td width=20%>";
echo $row["Fecha"];
echo"</td>";
echo"</td>";
echo"</tr>";
}
echo"</table>";
echo"<br>";
echo"<br>";
echo"</center>";

?>
</body>


ESPERO ME PUEDAN AYUDAR!!!