Re: Hacer un query a un Array

From: Date: Fri, 18 Mar 2005 17:50:24 +0000
Subject: Re: Hacer un query a un Array
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-53708@lists.php.net to get a copy of this message
Hola, Eso no es válido dentro de una cláusula SQL, lo que puedes hacer es poner los itmes de ese arreglo en una cadena separada con comas y despues hacer: $sql1='SELECT * FROM orders WHERE clientid IN ("'.$arr_clients.'") and status="N"'; donde $arr_clients tendria algo como "1,2,5,7,13,2231" Saludos. Jesús Guadalupe Reyna Tovar Monterrey, Nuevo León, México http://www.jesusreyna.org Linux User # 320213 -----BEGIN GEEK CODE BLOCK----- GCS !d s++:++un--C++UPL++EW?n!ok-W ?O!M?VPSPE++Y?PGPt?5X++Rtv+b-DID+ Ge+¡h!r+y+ ------END GEEK CODE BLOCK------
                   www.geekcode.com
Oswaldo Otero wrote:
Hola a todos, quiero hacer algo como mandar un query a un arry, en la clausula where eso se puede, creen que existe otra forma de hacerlo. Seria algo como esto. <?session_start(); include('../config.php'); //So here start the really hard work, this is a really, lib, for //get how many are there pending for be check by the doctor. //That's it.. //-------------First //A simple SQL, Connection $connection=mysql_connect($db_host,$db_user,$db_pass); $selection=mysql_select_db('grouprx_com',$connection); //-------------Second //So we have to make and array, for get all the clients, taht this doctor have to attend... //This query is for get, what client work with the login doctor... //By the way, we make a array, for consult the order table... $sql='SELECT * FROM clientdoctor WHERE doctorid ="'.$doctorid.'"'; $result=mysql_db_query($db,$sql); $how_many_clients=mysql_num_rows($result); //------------Third //Then, we have to get all the client id of the people(clients) and put them in an array... for($i=0;$i < $how_many_clients;$i++) { $data=mysql_fetch_array($result); $arr_clients[$i]=$data['clientid']; } //-------------Fourth //Well Done, we got the array, so let us try if we can run another query where the WHERE condition is executable into and array=====>>>$arr_clients. $sql1='SELECT * FROM orders WHERE clientid="'.$arr_clients.'" and status="N"'; $result1=mysql_db_query($db,$sql1); $pending_orders=mysql_num_rows($result1); ?> Si ven en la sentencia $sql1, quiero meter por clausula un array, eso se puede???? Como podria hacerse algo similar... Gracias por las ideas


« previous php.general.es (#53708) next »