Adobe Dreamweaver Forums



Last 10 THreads :         Re: Change Book or Page Icons? (Last Post : garythebadger - Replies : 0 - Views : 1 )           »          Embedded hyperlink doesn't work (Last Post : Racer-EX - Replies : 0 - Views : 1 )           »          RoboHelp hanging (Last Post : shawntrident - Replies : 4 - Views : 5 )           »          advice please (Last Post : NedWebs - Replies : 1 - Views : 2 )           »          Spry Accordion Panel Default State All Closed? (Last Post : David Powers - Replies : 1 - Views : 2 )           »          Is there a time limit for a full-motion recording? (Last Post : CatBandit - Replies : 2 - Views : 3 )           »          CS4 slow in Leopard (Last Post : Jim Babbage .:CMX:. & .:Adobe Community Expert:. - Replies : 1 - Views : 2 )           »          Spry menu hover issue (Last Post : danantal - Replies : 0 - Views : 1 )           »          Writing in different languages (Last Post : neebie - Replies : 0 - Views : 1 )           »          DW creating wrong ASP recordset (Last Post : Edson Correa - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags: ,



Reply
  #1 (permalink)  
Old 04-13-2008, 02:51 AM
The_FedEx_Guy
 
Posts: n/a
Diggs:
Default SQL Issue

I have a problem with my SQL, it will return values if I submit nothing into my
searchbox or it will find one matching value and display results for that, I
would like a match for exact search values, mainly on price.

Also is there a way I can dynamically display a drop down box with different
values to the one I already have?

// define an array of acceptable property types
$propTypes = array('Houses', 'Flats/Apartments', 'Bungalows','Commercial');
// if submitted value is in the array of acceptable types, use it
// otherwise, use a wildcard character
if (isset($_REQUEST['PropType']) && in_array($_REQUEST['PropType'],
$propTypes)) {
$PropType = "= '".$_REQUEST['PropType']."'";
} else {
$PropType = "LIKE '%'";
}


// check that the number of bedrooms is a number
// if it's zero, search for all numbers
if (isset($_REQUEST['NoBeds']) && is_numeric($_REQUEST['NoBeds']) &&
$_REQUEST['NoBeds'] == 0) {
$NoBeds = '> 0';
} elseif (isset($_REQUEST['NoBeds']) && is_numeric($_REQUEST['NoBeds']) &&
$_REQUEST['NoBeds'] > 0) {
$NoBeds = '= '.$_REQUEST['NoBeds'];
} else {
$NoBeds = '> 0';
}

// if minPrice is not a number, set it to zero
// otherwise, use the submitted value
if (isset($_REQUEST['minPrice']) && !is_numeric($_REQUEST['minPrice']) ||
!isset($_REQUEST['minPrice'])) {
$minPrice = 0;
} elseif (isset($_REQUEST['minPrice']) && is_numeric($_REQUEST['minPrice'])) {
$minPrice = $_REQUEST['minPrice'];
}

// if maxPrice is not a number, set it to 100 million
// otherwise, use the submitted value
if (isset($_REQUEST['maxPrice']) && !is_numeric($_REQUEST['maxPrice']) ||
!isset($_REQUEST['maxPrice'])) {
$minPrice = 100000000;
} elseif (isset($_REQUEST['maxPrice']) && is_numeric($_REQUEST['maxPrice'])) {
$minPrice = $_REQUEST['maxPrice'];
}
mysql_select_db($database_db, $db);

$query_Recordset1 = "SELECT * FROM property WHERE B_R = '$_POST[B_R]' AND
Accepted = 'Yes' AND
(City = '$_POST[q]') Or Postcode LIKE '%$q' Or Area = '$_POST[q]' AND
PropType $PropType AND NoBeds $NoBeds AND Country = 'UK' AND
Cost BETWEEN $minPrice AND $maxPrice ORDER BY Cost $sort";

$Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);




Reply With Quote
Sponsored Links
Reply


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

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



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 06:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk