PHP General :: HELP!! Searching on Multiple Fields
This thread was displayed: 346 times
Starting with 17th May 2007, Adobe Systems will stop offering support for any version of the discontinued InterAKT products. As a result, we will not answer to new support incidents starting with May 17th, 2007. Pending support incidents will still be followed in order to be closed. The product forums will remain open and be transformed in user-to-user forums. The general forums will be made read-only and not allow new posts or comments.
For more information about the affected products visit: www.interaktonline.com/Support/
Paul Flaherty
04-12-2005 23:33:37 GMT +2
|
I have been banging my head for a few weeks now trying to figure out how to search on drop down menus whereby the user can select everything or a value from a particular field.
I thought i would ask to see if you would be so kind enough to post a tutorial on how to do this step by step as i reckon other people other than me would find it very very useful. I know how to use % in the search fields although when use it, it returns all the fields and ignores the other values. It would be good to show how a user can select All from one field but select a value from another field using an AND statement from the query. For example Type = Buy, Let or All Property = Semi-detached, Detached, Bungalow, Mansion or All so the user can select all the properties with either Buy or Let and then a value from the Property field. Best Regards Paul
|
|
|
Razvan Racasanu[InterAKT]
04-14-2005 17:19:12 GMT +2
|
Hello,
A solution to your problem would be a recordset, in which the WHERE clause would contain something like: WHERE field1 LIKE '%param1%' AND field1 LIKE '%param2%', where param1 and param2 are the values posted from the dropdowns. When creating the dropdowns, create an item named All with it's value set to "" (null string). For all other items, enter their corresponding values.
Regards, Razvan RACASANU
|
|
|
Paul Flaherty
04-14-2005 17:28:56 GMT +2
|
Hi Razvan RACASANU
Thanks for your assistance, i will give it ago in about half an hour and see how i get on.
Best Regards
Paul
|
|
|
Paul Flaherty
04-15-2005 20:28:13 GMT +2
|
Hi Razvan RACASANU
I think i am struggling with this. When i leave the type blank in the form then it just passes type as the url ie type=type therefore bringing up no results when searching on Type=All with a value from the location field.
I would be grateful if you could help me.
<?php // Load the tNG classes require_once('../includes/tng/tNG.inc.php');
$colname_rsProperties = "%"; if (isset($_GET['type'])) { $colname_rsProperties = (get_magic_quotes_gpc()) ? $_GET['type'] : addslashes($_GET['type']); } $colname1_rsProperties = "-1"; if (isset($_GET['location'])) { $colname1_rsProperties = (get_magic_quotes_gpc()) ? $_GET['location'] : addslashes($_GET['location']); } mysql_select_db($database_newproperty, $newproperty); $query_rsProperties = sprintf("SELECT * FROM property WHERE type LIKE '%%%s%%' AND location LIKE '%%%s%%'", $colname_rsProperties,$colname1_rsProperties); $rsProperties = mysql_query($query_rsProperties, $newproperty) or die(mysql_error()); $row_rsProperties = mysql_fetch_assoc($rsProperties); $totalRows_rsProperties = mysql_num_rows($rsProperties); ?>
|
|
|
Razvan Racasanu[InterAKT]
04-18-2005 08:29:52 GMT +2
|
Hello,
If you have created the items from the Dreamweaver interface and left the value empty, then Dreamweaver did not add an value parameter to the item. This will cause the browser to send the item label as the value. To fix this, you will have to manually edit the file and add the value="" to the "All" dropdown item.
Regards, Razvan RACASANU
|
|
|