Hi
I am trying to amend a search of an image database. The search works fine on single keywords, but if I add two separate keywords in the search it will come up with a result of 0, even though both keywords are in the database separately. I am new to this and am not sure whether I can add both words together as another key in the database, or what is the best way to allow the search to pick up the images. It seems to me that there must be a simpler and more elegant and better way of doing this with the SQL and PHP code?
if(isset($HTTP_POST_VARS['searchme']) ) { // true if search has been submitted
if ($HTTP_POST_VARS['keys'] == "") {
$Criteria = "";
} else {
$Criteria = " AND ((k.key_word LIKE '%".$HTTP_POST_VARS['keys']."%')";
$Criteria .= " OR (i.img_desc LIKE '%".$HTTP_POST_VARS['keys']."%')";
$Criteria .= " OR (i.img_title LIKE '%".$HTTP_POST_VARS['keys']."%'))";
}
if ($HTTP_POST_VARS['img_category'] <> "999") { //search a specific category
$Criteria .= " AND k.key_word=".GetSQLValueString($HTTP_POST_VARS['img_category'], "text")." ";
}
Any help would be very gratefully received.
Thank you
I am trying to amend a search of an image database. The search works fine on single keywords, but if I add two separate keywords in the search it will come up with a result of 0, even though both keywords are in the database separately. I am new to this and am not sure whether I can add both words together as another key in the database, or what is the best way to allow the search to pick up the images. It seems to me that there must be a simpler and more elegant and better way of doing this with the SQL and PHP code?
if(isset($HTTP_POST_VARS['searchme']) ) { // true if search has been submitted
if ($HTTP_POST_VARS['keys'] == "") {
$Criteria = "";
} else {
$Criteria = " AND ((k.key_word LIKE '%".$HTTP_POST_VARS['keys']."%')";
$Criteria .= " OR (i.img_desc LIKE '%".$HTTP_POST_VARS['keys']."%')";
$Criteria .= " OR (i.img_title LIKE '%".$HTTP_POST_VARS['keys']."%'))";
}
if ($HTTP_POST_VARS['img_category'] <> "999") { //search a specific category
$Criteria .= " AND k.key_word=".GetSQLValueString($HTTP_POST_VARS['img_category'], "text")." ";
}
Any help would be very gratefully received.
Thank you