Tema: implode
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 30/05/2011, 11:36
charlyta
 
Fecha de Ingreso: junio-2008
Mensajes: 291
Antigüedad: 15 años, 10 meses
Puntos: 9
Respuesta: implode

este es lo code completo:

Código PHP:
Ver original
  1. <?php
  2. $user="root";
  3. $host="localhost";
  4. $password="";
  5. $database = "libros";
  6. $connection = mysql_connect($host,$user,$password)
  7. or die ("couldn't connect to server");
  8. $db = mysql_select_db($database,$connection)
  9. or die ("Couldn't select database");
  10.  
  11.  
  12.  
  13. $where = array();
  14. foreach ($_GET as $key => $value){
  15. if ($_GET ['key']) {
  16. $_GET['value'] = str_replace("'","",$_GET['value']);
  17. $where[]="'".$_GET['key']."=".$_GET['value']."'";
  18.  
  19. }
  20. }
  21. $sql = "SELECT * FROM libros WHERE ".implode(" AND ",$where).";";
  22. echo $where;
  23.  
  24. echo '<pre>' . $sql . '</pre>';
  25. ?>