Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/11/2014, 13:27
ocp001a
Colaborador
 
Fecha de Ingreso: mayo-2008
Ubicación: $MX['VZ']['Xalapa']
Mensajes: 3.005
Antigüedad: 16 años
Puntos: 528
Respuesta: isset comparación

Tienes que definir un criterio de consulta:

Código PHP:
Ver original
  1. if (isset($_GET['name'])) { //si se solicita el término a buscar
  2.         // Create the query
  3.         $data = "%".$_GET['name']."%";
  4.         $sql = 'SELECT * FROM employee WHERE name like ?'; //hacemos la búsqueda
  5.     }else//si no se solicita la búsqueda
  6.        $sql="La consulta predefinida que quieras mostrar";//definimos la consulta por defecto
  7.  
  8.  
  9. // we have to tell the PDO that we are going to send values to the query
  10. $stmt = $conn->prepare($sql);
  11. // Now we execute the query passing an array toe execute();
  12. $results = $stmt->execute(array($data));
  13. // Extract the values from $result
  14. $rows = $stmt->fetchAll();
  15. $error = $stmt->errorInfo();
  16. //echo $error[2];