Dear All,
I am trying to extract records from a table that have a catid of 2 AND are like the string entered into a search field i.e. a record with a catid of 2 AND a date LIKE 2011-04-29 however when the query is run it returns ALL records LIKE the string and ignores the AND catid = 2 bit. So it returns the records matching that date but doesn't filter them further to display only those records matching the date AND have a catid of 2.
Can anyone explain what changes I need to make so that I can get the result I need.
TIA and Regards
Chris Blair
I am trying to extract records from a table that have a catid of 2 AND are like the string entered into a search field i.e. a record with a catid of 2 AND a date LIKE 2011-04-29 however when the query is run it returns ALL records LIKE the string and ignores the AND catid = 2 bit. So it returns the records matching that date but doesn't filter them further to display only those records matching the date AND have a catid of 2.
<?php
$title = JRequest::getString('title', '', 'post');
if ( $title ) {
}
echo " WHERE (`date` LIKE '%$title%' OR `description` LIKE '%$title%' OR `title` LIKE '%$title%') AND (`catid` = 2)";
?>
Can anyone explain what changes I need to make so that I can get the result I need.
TIA and Regards
Chris Blair
Hi Chris,
Looks OK to me and tests OK when I run a slightly modified version on jos_content.
Check the column title is catid and not CatId or som other variant?
Bob
PS Minor point but the closing } should be after the echo line.
Looks OK to me and tests OK when I run a slightly modified version on jos_content.
Check the column title is catid and not CatId or som other variant?
Bob
PS Minor point but the closing } should be after the echo line.
Hi Bob,
It's been a while - hope all is well. Thanks for the response however, I still can't get the correct record set returned. The column name is correct (catid), as are the others. I have gone through everything with a fine tooth comb but still falling short somewhere. I also put the } in the correct place - that was a copy and paste weirdness.
Regards
Chris
It's been a while - hope all is well. Thanks for the response however, I still can't get the correct record set returned. The column name is correct (catid), as are the others. I have gone through everything with a fine tooth comb but still falling short somewhere. I also put the } in the correct place - that was a copy and paste weirdness.
Regards
Chris
This topic is locked and no more replies can be posted.