Simple Search Logic Issue...
| From: | revDAVE | Date: | Sun, 15 Feb 2009 00:01:51 +0000 |
| Subject: | Simple Search Logic Issue... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-288274@lists.php.net to get a copy of this message | ||
Newbie question...
I have a search page with multi lines of search criteria:
Name
Topic
Message
Etc...
I'm hoping to get results based on what criteria I type - but I'm not
getting what I expect. I think it's just getting results where in addition
to getting search criteria I type - ALSO none of the search fields can be
blank (not what I hoped) ...
Like I type just 'c' in the name field and it shows 3 records (other search
fields filled up) ... But I have many more records with name containing 'c'
Goal: to search for what I type in whatever search fields and not worry
about whether others are blank or not - like:
Name contains 'c'
Charles
Chuck
Chuck
Chas
Or
Name contains 'c' and topic contains 'test1'
Maybe just charles fits this criteria
----------
I made a simple results page,
... More code here ... ( DW CS3 )
$name_list1 = "-1";
if (isset($_GET['Name'])) {
$name_list1 = $_GET['Name'];
}
$top_list1 = "-1";
if (isset($_GET['Topic'])) {
$top_list1 = $_GET['Topic'];
}
$mess_list1 = "-1";
if (isset($_GET['Message'])) {
$mess_list1 = $_GET['Message'];
}
mysql_select_db($database_test1, $test1);
$query_list1 = sprintf("SELECT * FROM mytable WHERE Name LIKE %s and Message
LIKE %s and Topic LIKE %s ORDER BY mytable.id desc", GetSQLValueString("%" .
$name_list1 . "%", "text"),GetSQLValueString("%" . $mess_list1 .
"%",
"text"),GetSQLValueString("%" . $top_list1 . "%", "text"));
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]