Re: Búsquedas múltiples

From: Date: Tue, 20 Feb 2001 12:16:32 +0000
Subject: Re: Búsquedas múltiples
References: 1 2  Groups: php.general.es 
Request: Send a blank email to general-es+get-7273@lists.php.net to get a copy of this message
Realmente la línea $strSelectAsesoría="SELECT DISTINCT * FROM Asesoría WHERE Definitivo=1 AND " . $variable; debe ser $strSelectAsesoría="SELECT DISTINCT * FROM Asesoría WHERE Definitivo=1 " . $variable; porque el AND ya va en $variable. Ha sido un desliz por las prisas. joseluis.jimenez@sema.es wrote: > ¿Has probado haciendo ...? > > if ($BOTON == 'Buscar') > { > if ($C1==1) > { > $var1=" AND Código='$nom1[0]'"; > } > if ($C6==1) > { > $var6=" AND Expediente='$nom6[0]'"; > } > if ($C2==1) > { > $var2=" AND Delegación='$nom2[0]'"; > } > if ($C3==1) > { > $var3=" AND Fecha_ad='$nom3[0]'"; > } > if ($C4==1) > { > $var4=" AND Responsable='$nom4[0]'"; > } > if ($C5==1) > { > $var5=" AND Centro='$nom5[0]'"; > } > $variable=$var1.$var6.$var2.$var3.$var4.$var5; > print "--$variable-- --$var1-- --$C1-- --$nom1[0]--"; > $conn=odbc_connect("tempdb","Admin","XXXX") or die > ("Imposible conectarse a la base de datos"); > $strSelectAsesoría="SELECT DISTINCT * FROM Asesoría WHERE Definitivo=1 AND " . > $variable; > > Un saludo y suerte. > > Victor del Burgo wrote: > > > Buenass: > > > > ¿Se pueden hacer búsquedas múltiples en PHP? > > Me salen errores en la línea de la sentencia SELECT y me parece que es porque no admite > > variables...... > > > > El código es este: > > > > if ($BOTON == 'Buscar') > > { > > if ($C1==1) > > { > > $var1="Código='$nom1[0]'"; > > } > > if ($C6==1) > > { > > $var6="Expediente='$nom6[0]'"; > > } > > if ($C2==1) > > { > > $var2="Delegación='$nom2[0]'"; > > } > > if ($C3==1) > > { > > $var3="Fecha_ad='$nom3[0]'"; > > } > > if ($C4==1) > > { > > $var4="Responsable='$nom4[0]'"; > > } > > if ($C5==1) > > { > > $var5="Centro='$nom5[0]'"; > > } > > $variable=$var1.$var6.$var2.$var3.$var4.$var5; > > print "--$variable-- --$var1-- --$C1-- --$nom1[0]--"; > > $conn=odbc_connect("tempdb","Admin","XXXX") or die > > ("Imposible conectarse a la base de datos"); > > $strSelectAsesoría="SELECT DISTINCT * FROM Asesoría WHERE '$variable' > > AND Definitivo=1"; > > $rsAsesoría=odbc_exec($conn,$strSelectAsesoría); > > > > if (true) > > { > > print "<center><font size=2><table border=1 cellspacing=0 > > width=100%><tr><td><b><center>Expediente</center></b></td><td><b><center>Asunto</center></b></td><td><b><center>Demandante</center></b></td><td><b><center>Demandado</center></b></td><td><b><center>Responsable</center></b></td><td><b><center>Cuantía</center></b></td><td><b><center>Procedimiento</center></b></td><td><b><center>Código</center></b></td></font></center></tr>\r\n"; > > while (odbc_fetch_row($rsAsesoría)) > > { > > $fieldExp=odbc_result($rsAsesoría,1); > > $fieldAsun=odbc_result($rsAsesoría,4); > > $fieldDdte=odbc_result($rsAsesoría,5); > > $fieldDdo=odbc_result($rsAsesoría,6); > > $fieldResp=odbc_result($rsAsesoría,7); > > $fieldCuan=odbc_result($rsAsesoría,8); > > $fieldProc=odbc_result($rsAsesoría,9); > > $fieldCod=odbc_result($rsAsesoría,11); > > print "<tr>"; > > print "<td><font size=2><center><a > > href='http://www/pruebas/Asesoria_ver.php3?fieldExp=$fieldExp' > > >$fieldExp</a></center></font></td>"; > > print "<td><font > > size=2><center>$fieldAsun</center></font></td>"; > > print "<td><font > > size=2><center>$fieldDdte</center></font></td>"; > > print "<td><font > > size=2><center>$fieldDdo</center></font></td>"; > > print "<td><font > > size=2><center>$fieldResp</center></font></td>"; > > print "<td><font > > size=2><center>$fieldCuan</center></font></td>"; > > print "<td><font > > size=2><center>$fieldProc</center></font></td>"; > > print "<td><font > > size=2><center>$fieldCod</center></font></td>"; > > print "</tr>\r\n"; > > } > > print "</table></center>"; > > } > > $rsAsesoría=odbc_exec($conn,$strSelectAsesoría); > > } > > > > .... Se supone que C1, C2, ..... son CheckBox que cuando se activen y se pulse sobre el > > botón 'BOTON', realizará la búsqueda sólo por los campos en los que la casilla esté > > marcada..... > > > > .... nom1[0], nom2[0],.... son los combos en los que se seleccionan los campos por los que > > hacer la búsqueda, que suelen tener este formato: > > > > if (true) > > { > > while (odbc_fetch_row($rsAsesoría)) > > { > > $fieldCen=odbc_result($rsAsesoría,1); > > if ($fieldCen!='') > > print "<option value='nom5[]=$fieldCen'>$fieldCen"; > > } > > print "</select>"; > > } > > > > No sé que hacer, y lo necesito urgentemente.... > > > > Salu2 > > > > -VICTOR- > > ------------------------------------------------------------------ > This email is confidential and intended solely for the use of the individual to whom it is > addressed. Any views or opinions presented are solely those of the author and do not necessarily > represent those of Sema Group. > If you are not the intended recipient, be advised that you have received this email in error > and that any use, dissemination, forwarding, printing, or copying of this email is strictly > prohibited. > ------------------------------------------------------------------ > > --------------------------------------------------------------------- > Archivo On-line: http://www.phpes.com/ > Manual PHP en español: http://www.php.net/manual/es/ > Para dar de baja la suscripción, mande un mensaje a: > lista-unsubscribe@phpes.com ------------------------------------------------------------------ This email is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Sema Group. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. ------------------------------------------------------------------

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