anthony-needs-you Posted January 5, 2009 Share Posted January 5, 2009 Hi i have two bits of code. On their own they work fine. How would i put them together? $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE destination LIKE '%$where%'");[code] $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE duration LIKE '%$stay%'");[/code] Link to comment https://forums.phpfreaks.com/topic/139579-solved-searching-for-multiple-keywords/ Share on other sites More sharing options...
premiso Posted January 5, 2009 Share Posted January 5, 2009 WHERE destination LIKE '%$where%' OR duration LIKE '%$stay%' Or keyword in the WHERE clause if you want either or AND if you want both to be true.... WHERE destination LIKE '%$where%' AND duration LIKE '%$stay%' Link to comment https://forums.phpfreaks.com/topic/139579-solved-searching-for-multiple-keywords/#findComment-730180 Share on other sites More sharing options...
Maq Posted January 5, 2009 Share Posted January 5, 2009 Have you tried appending another conditional? I think that should work. $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE destination LIKE '%$where%' AND duration LIKE '%$stay%'"); Link to comment https://forums.phpfreaks.com/topic/139579-solved-searching-for-multiple-keywords/#findComment-730181 Share on other sites More sharing options...
Maq Posted January 5, 2009 Share Posted January 5, 2009 'OR' & 'AND' should both work depending on what restrictions you want. But looks like premiso is right with the 'OR' Link to comment https://forums.phpfreaks.com/topic/139579-solved-searching-for-multiple-keywords/#findComment-730184 Share on other sites More sharing options...
anthony-needs-you Posted January 5, 2009 Author Share Posted January 5, 2009 Thanks works perfectly Link to comment https://forums.phpfreaks.com/topic/139579-solved-searching-for-multiple-keywords/#findComment-730186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.