Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/07/2016, 20:27
eridamega
 
Fecha de Ingreso: enero-2013
Mensajes: 9
Antigüedad: 11 años, 3 meses
Puntos: 0
Mostar mensaje cuando la búsqueda no encuentra resultados

Hola Amigos, esoy tratando de aprender php pero he salido
Tengo un formulario de busqueda a una base de datos msql con los datos (nombre, documento, track(guia) y empresa de envio, esta funcional, muestra las busquedas perfectamente, cuando alguien ingresa su documento y esta en la bd. Pero yo deseo que cuando alguien ingrese un documento y no este en la base de datos diga un mensaje como por ejemplo (no se encontraron registros)

Alguien podria ayudarme en eso...
llevo muchos dias en esto y no he podido hacerlo

este el el codigo del php
Código HTML:
<html>
<head>
  <title>Programando Ando</title>
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

  <!-- Latest compiled and minified JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>

<div class="row">
  <div class="col-md-4"></div>
  <div class="col-md-4">



    <center><h4>CONSULTA TU GUIA DE ENVIO</h4></center>

    <form method="POST" action="registro.php" >

    <div class="form-group">
      <label for="cedula">Documento</label>
      <input type="text" name="cedula" class="form-control" id="cedula">
  </div>

     <center>
    
      <input type="submit" value="Consultar" class="btn btn-info" name="btn2">
    </center>

  </form>



  <?php

    if(isset($_POST['btn2']))
    {
      include("abrir_conexion.php");

        $doc = $_POST['cedula'];
        
        if($doc=="") //VERIFICO QUE AGREGEN UN DOCUMENTO OBLIGATORIAMENTE.
          {echo "Digita un documento por favor. (Ej: 123)";}
        else
        {  
          $resultados = mysqli_query($conexion,"SELECT * FROM $tabla WHERE cedula = $doc");
          while($consulta = mysqli_fetch_array($resultados))
          {
            echo 
            "
              <table width=\"100%\" border=\"1\">
                <tr>
                  <td height=\"28\"><b>Nombre</b></td><td>".$consulta['nombre']."</td>
                </tr>
                <tr>
                  <td height=\"28\"><b>Documento</b></td><td>".$consulta['cedula']."</td>
                </tr>
                <tr>
                  <td height=\"28\"><b>Guia</b></td><td>".$consulta['numerode']."</td>
                </tr>
                <tr>
                  <td height=\"28\"><b>Empresa de envio</b></td><td>".$consulta['empresade25']."</td>
                </tr>
                <tr>
                  <td height=\"28\"><b>Nota</b></td><td>".$consulta['nota']."</td>
                </tr>
                <tr>
                  <td height=\"28\"><b>Comentarios</b></td><td>".$consulta['comentarios']."</td>
                </tr>
                
              </table>
            ";
          }
        }

      include("cerrar_conexion.php");
    }
  ?>



  </div>
  <div class="col-md-4"></div>
</div>



  
  
</body>
</html>