Re: Hacer un query a un Array

From: Date: Fri, 18 Mar 2005 18:00:49 +0000
Subject: Re: Hacer un query a un Array
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-53705@lists.php.net to get a copy of this message
Hola Oswaldo. No, no se puede. Lo que estas haciendo no es "pasarle" algo. Estas armando una cadena que va a contener tu consulta, no tiene sentido pensar en "meterle por clausula un array php". Podés hacer un for y armarte varios queries, o armarte una consulta con or , o si no pensar un poco mas el sql y plantearlo como un join o un where. Digamos algo así: "SELECT * FROM orders WHERE idclient=$data[1] OR idclient=$data[2] " y asi seguis adentro del for. O si no: "SELECT orders.* FROM clientdoctor,orders WHERE clientdoctor.clientid = orders.clientid AND clientdoctor='$iddoctor'" Y este te va a traer justo lo que estas buscando. Entre parentesis, cuando pases código a la lista, tratá de extraerle los comentarios, en casos como este es bastante molesto. Saludos. Pablo E. Siciliano. ----- Original Message ----- From: "Oswaldo Otero" <oswaldo.otero@gmail.com> To: <php-es@lists.php.net> Sent: Friday, March 18, 2005 1:38 PM Subject: [PHP-ES] Hacer un query a un Array > 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 > -- > Oswaldo Otero en Gmail > > La "G" es de GEEK > > -- > PHP Spanish Localization Talk Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 2005-03-15 > >

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