Jump to content


Photo

Como Fazer Busca Entre 2 Valores?


  • Faça o login para participar
26 replies to this topic

#1 sensuais

sensuais

    Turista

  • Usuários
  • 37 posts
  • Sexo:Não informado

Posted 20/08/2003, 11:48

Olá galera, tenho mais uma dúvida.
Olhem no código abaixo os IFs que coloquei para fazer uma Concatenação, no "DORM", ele usa o "in" para procurar por 2,3 por exemplo, agora quero fazer o mesmo com o "PRECO" porem o preço não da para usar como o DORM que é 2 ou 3 pois o preço é entre 100,00 e 500,00, ai pode ter uma infinidade de opções, pois o valor pode ser quebrado como por exemplo 250,00.
Ai o que eu faço? Uso and? Acho que não! or também não, pois não é um ou outro.

Me deem uma ajuda por favor.
Quero algo assim:

if ($txt_preco == "1") $sql .= " and preco = '100,00 até 300,00' ";
if ($txt_preco == "2") $sql .= " and preco = '301,00 até 500,00' ";
if ($txt_preco == "3") $sql .= " and preco = '501,00 até 1.000,00' ";
e assim por diante, mais ai eu faço depois, primeiro tenho que descobrir o que uso nesse código para substituir esse até que coloquei ai.


Abaixo meu cóigo atual.

<?
$conec ;
$bco ;
$conectou = 0;
include "conexao.php" ;
if ($conectou) {

$sql = "select * from tb_imoveis where para = '$txt_para' " ;

if ($txt_tipo != "") $sql .= " and tipo = '$txt_tipo' ";
if ($txt_bairro != "") $sql .= " and bairro = '$txt_bairro' ";
if ($txt_dorm == "1") $sql .= " and dorm = 1 ";
if ($txt_dorm == "2") $sql .= " and dorm in (2,3) ";
if ($txt_dorm == "4") $sql .= " and dorm in (4,5) ";
if ($txt_dorm == "5") $sql .= " and dorm >= 5 ";
if ($txt_preco != "") $sql .= " and preco <= '$txt_preco' ";

$res = mysql_query($sql,$conec);

$linhas = mysql_num_rows($res) ;

if (($res) and ($linhas)) {
include "selecionapesquisa.php" ;
}

else {
echo "Nenhum imóvel encontrado nesse perfil.";
echo "<br><a href='java script:history.go(-1)'><< Voltar</a><br>";

} //fecha else
} //fecha conectou
?>



Falo galera... :ph34r:

#2 hail

hail

    Normal

  • Usuários
  • 78 posts
  • Sexo:Não informado

Posted 20/08/2003, 14:29

nao entendi direito... to meio cuzido... mas vo tentar..

pra pesquisar entre dois valores (inclusos) vc usa algo assim...
valores entre 10 e 20

sintaxe php
if ( $val>=10 && $val<=20) {

sintaxe sql
select * from tabela where campo between 10 and 20


[]s

#3 Stormbringer

Stormbringer

    I'd love to stay with you all

  • Ex-Admins
  • 2927 posts
  • Sexo:Não informado
  • Localidade:Goiânia - GO
  • Interesses:Atualmente: pesquisa e desenvolvimento de web-games

Posted 20/08/2003, 14:34

ou ainda

select campos from tabela where campov => 10 AND campov <=100 ;

e acredite, esse jeito não é mais elegante do que o hail passou... mas se a sua aplicação for crescendo, crescendo... pra vc mudar algo é sempre melhor optar pelo metodo menos "elegante"...

sei disso por experiencia propria :D

๑۩۞۩๑Let the Carnage Begin!!๑۩۞۩๑


#4 sensuais

sensuais

    Turista

  • Usuários
  • 37 posts
  • Sexo:Não informado

Posted 20/08/2003, 15:35

Valeu galera, vou testar e falo para vcs.... OK

#5 sensuais

sensuais

    Turista

  • Usuários
  • 37 posts
  • Sexo:Não informado

Posted 20/08/2003, 21:43

Ai galera valeu em!

Ta funcionando e ficou assim:


$sql = "select * from tb_imoveis where para = '$txt_para' " ;

if ($txt_tipo != "") $sql .= " and tipo = '$txt_tipo' ";
if ($txt_bairro != "") $sql .= " and bairro = '$txt_bairro' ";
if ($txt_dorm == "1") $sql .= " and dorm = 1 ";
if ($txt_dorm == "2") $sql .= " and dorm in (2,3) ";
if ($txt_dorm == "4") $sql .= " and dorm in (4,5) ";
if ($txt_dorm == "5") $sql .= " and dorm >= 5 ";
if ($txt_preco == "1") $sql .= " and preco between 100.00 and 200.00";
if ($txt_preco == "2") $sql .= " and preco between 200.00 and 300.00";
if ($txt_preco == "3") $sql .= " and preco between 300.00 and 500.00";
if ($txt_preco == "4") $sql .= " and preco between 500.00 and 800.00";
if ($txt_preco == "5") $sql .= " and preco between 800.00 and 1000.00";
if ($txt_preco == "6") $sql .= " and preco between 1000.00 and 5000.00";
if ($txt_preco == "7") $sql .= " and preco between 5000.00 and 10000.00";
if ($txt_preco == "8") $sql .= " and preco between 10000.00 and 50000.00";
if ($txt_preco == "9") $sql .= " and preco between 50000.00 and 100000.00";
if ($txt_preco == "10") $sql .= " and preco >= 100000.00 ";

#6 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 25/09/2017, 14:49

Cialis Barcelona En Mano cialis buy online Cialis Vente Libre Canada

#7 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 15/10/2017, 12:31

Can I Take Sudafed With Amoxicillin buy viagra online Ed Sample Pack Cheap Buy Now Online Viagra

#8 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 30/10/2017, 11:05

Zoa Ciprofloxacin Et Alcool Ofloxacin cialis levitra sales viagra For Sale Legally Progesterone Visa Best Website. Buy Progesterone Discount Low Price

#9 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 13201 posts

Posted 31/10/2017, 10:10

Propecia Cruz Roja viagra online pharmacy Promosiones De Viagra
Proscar Euros Propecia Amoxicillin Suspention Dosage For Cat where can you buy levitra the cheapest Amoxicillin And Clavulante Levitra 10mg Belgique Corporacion Dermoestetica Propecia
Viagra Rezeptfrei Kaufen Forum Cialis Thru Canadian Supplier viagra Rxpills Cialis Forum Cialis 5 Mg Does Amoxicillin Work On Uti
Buy Cheap Furosemide Levitra Package Insert Il Dangereux viagra Amoxicillin Rash Picture Viagra Turk
Levitra Brand Propecia Criticas Where Can I Buy Ciprobay 500 Mg levitra online Brand Cialis And Levitra

#10 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 02/11/2017, 08:46

Amoxicillin Reconstitution Discount Clobetasol Cash Delivery Tab Pharmacy viagra prescription Propecia Doping Garantia De Satisfaccion Comment To Last Longe
Where Can Buy Viagra Cheapest Price Viagra Online Fast levitra samples overnight Diflucan Epocrates Online
Alli Online viagra prescription Difference Between Amoxicillin And Azithromycin Zithromax
2064 Prednisone For Sale Woher Kriege Ich Levitra Dapoxetina Yahoo best site to buy levitra Amoxil Duo
Vigria Viagra Sante Canada viagra Pursues Viagra With A Gift Card
Aygestin viagra Where Can I Get Metformin Online

#11 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 03/11/2017, 16:33

Kamagra Chewable 100 Mg Canada viagra online pharmacy New Primatene Mist Release Date

#12 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 06/11/2017, 18:06

Doxycycline Online Cheap Buy Allopurinol Without A Prescription Compare Amoxicillin And Azithromycin viagra Propecia Minoxidil Together
Safe To Buy Viagra Online farmacie a san marino levitra bayer Amoxicillin And Hives
Amoxicillin Photosensitivity viagra Warfarin Without Prescription Celebrex Online No Prescription
Fluoxetine Tablet Over Night Henderson online pharmacy Super Kamagra Priligy Propecia Side Effects Allergy
Acheter Cialis 5 Mg Comprime Pellicule Boite De 28 Kidney Infection Can Amoxicillin Cause generic levitra online Acheter Amoxil Pharmacie
Buy Avodart Online Canada Olanzapine For Sale From Canada viagra online pharmacy Cialis Sottobanco Is Cephalexin Penacillin
Drugstore Priligy Dapoxetine En Ligne viagra Generic Macrobid On Sale Canada Mastercard Acceptedglucophage Achat Vrai Viagra Ligne Viagra Turkei
Propecia Diabetes Asma Cialis Online Us buy viagra online Precio Viagra De 100 Achat Kamagra Angleterre Brand Viagra Prices

#13 HaroNism

HaroNism

    Super Veterano

  • Usuários
  • 15385 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 07/11/2017, 08:27

Liquid Zithromax Cephalexin Dosing For Dogs Cialis Precio Mercadolibre generic viagra Amoxicillin For H Pylori Viagra Acquisto Online Cialis Super Active 20mg
Achat Viagra Internet Danger viagra online Cialis Indicazioni

#14 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 07/11/2017, 09:46

Medicine For Sale In Canada Sildenafil 100mg Kamagra A Buon Mercato buy viagra online buy accutane online canada Keflex Cephalexin Viagra Sale No Prescription
Propecia Neck Pain Cialis Vente Canada viagra Amitriptyline No Rx Needed Pdr Keflex Zithromax Picture
Pediatric Zithromax Dosage Cialis 20 Mg Costo Farmacia levitra brand online No Prescription Amoxicillin Cheap
Effect Of Tadalis Sx Soft Cialis Sin Receta Cheap Finasteride Propecia Online cialis online Order Celexa
Buy Provera Uk Generic Viagra X Mg Amoxicillin Dose Adult Strep Throat viagra Azithromycin From Amazon
Buy Neurontin Overnight Propecia Dunnes Haar buy levitra online Viagra Kaufen Fulda Propecia Contradicciones
Propecia Asepsia 1 3 Days Shipping On Ed Pills Generic Viagra Without A Prescription viagra Secure Ordering Provera Where To Buy Delivered On Saturday Cialis 10 Mg 4 St Examples Of Side Effects Of Propecia
Baclofene 10 Mg Fluoxetin Online Bestellen Ohne Rezept Canadian Pharmacy Online Drugstore generic viagra Viagra Aus Deutschland Bestellen

#15 HaroNism

HaroNism

    Super Veterano

  • Usuários
  • 15385 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 07/11/2017, 17:04

Supreme Suppliers Mumbai Buy Doxycycline Online Overnight Plavix Online Purchase viagra prescription Amoxil Damages Gall Bladder
Zithromax Gram Negative Coverage viagra Where To Buy Diuretic Lasix
Order Celebrex cialis Cialis Trial Packs Express Shipping Cialis Aspirina Generique Cialis Prix
Generic Viagra For Sale In Usa Center Kamagra Oral Jelly generic cialis Real Viagra Pills Cheapest Flagyl Generic Form
Cialis 5 Indications Omeprazole online pharmacy Buy Canine Amoxicillin
Cuanto Cuesta Cialis Original Viagra Versand Schweiz viagra Cheap Kamagra Now
Priligy Quanto Costa How To Identify Amoxicillin From Mexico cialis online Cost Zithromax Pentagesic buy accutane online forum
Cialis Shop Forum Cialis Pills Venta De Cialis Professional online pharmacy Propecia Caratteristiche Youtube Levitra Buy Alli Diet Pills Online
Cheap Viagra Fast buy viagra Baclofen Pas Cher 25mg Hydrochlorothiazide Visa Arun Tadalafil Sale
Generic Cialis 10 Mg Propecia Forehead viagra online Cephalexin Dog Skin Infection Amoxicillin 875 Dosage Peut On Avoir Du Viagra Sans Ordonnance




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq