Current location: Hot Scripts Forums » Programming Languages » PHP » Basic SQL Query Help


Basic SQL Query Help

Reply
  #1 (permalink)  
Old 02-28-05, 04:09 PM
djwayne_2004 djwayne_2004 is offline
Newbie Coder
 
Join Date: Jan 2005
Location: England
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Basic SQL Query Help

Hi Everyone,

I have a simple question for you all, would probably work it out for myself if i had the time . I have a very good knowledge of SQL so this should be easy for me but i have never come across using it before untill now... Basically i would like to specify some prices ranges in a drop down list which will be used to filter the returned data from mysql, i will have a column for price which the drop down list will search against. So i will need to query something like "BETWEEN 10.000 AND 20.000" but i'm not really sure on this one. I hope someone can help, i know this will be simple, i'll hit myself when i find out .

Thanks
Wayne
Reply With Quote
  #2 (permalink)  
Old 02-28-05, 04:23 PM
dodod dodod is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
<form action="<?php echo basename($PHP_SELF); ?>" method="post">
<select name=lowestPrice><option value=5>$5.00</option></select> - 
<select name=highestPrice><option value=75>$75.00</option></select><br>
<input type=submit value=FILTER name=AgoGo>
</form>
PHP Code:

<?php

if(isset($_POST['AgoGo'])) {

$minimumPrice $_POST['lowestPrice'];
$maximumPrice $_POST['highestPrice'];
//Select the database, etc... These are 2 example queries.

$query_rs_Table "SELECT * FROM table WHERE price > $minimumPrice AND < $maximumPrice"
$query2_rs_Table "SELECT * FROM table WHERE price BETWEEN $minimumPrice AND $maximumPrice";

//Display the information
do { echo $row['price']; echo $row['name']; } while(XXXXXXXX);
?>

Last edited by dodod; 02-28-05 at 04:27 PM.
Reply With Quote
  #3 (permalink)  
Old 02-28-05, 04:53 PM
djwayne_2004 djwayne_2004 is offline
Newbie Coder
 
Join Date: Jan 2005
Location: England
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Hi dodod,

I knew it was something really simple and yet i have used both SQL statements in similar cases. I'm sure this Thread will be helpful for some other people learning SQL.

Thanks again,
Wayne
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
More info SLAYER18 Job Offers & Assistance 1 01-17-05 05:06 AM
SQL Query Sting Help ksroadrunner13 ASP 1 10-17-04 02:56 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 05:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.