Php mysql query fetch array even when no keyword is given?

If ($needToCheckColumn4) { $query = "SELECT * FROM table WHERE Column1 LIKE'%$keyword%' AND Column4 = '$col4'"; } else { $query = "SELECT * FROM table WHERE Column1 LIKE'%$keyword%'"; }.

$query = "SELECT * FROM table WHERE Column1 LIKE'%$keyword%' AND Column4 LIKE '%$keyword2%'"; If $keyword2 is an empty string, it will match anything.

I want to use =, not LIKE – blasteralfred Mar 16 at 16:53 Then go with user138821's suggestion - although I would put $col4 in the if statement, as you don't need two variables. – Grim... Mar 16 at 16:55 k... I got it.. thanks.. :) – blasteralfred Mar 16 at 16:59.

I want to display results even if I am not giving any keyword for col4. But I can't avoid that part since I give some data for col4 sometime. Btw I want to display the data even if I have nothing to check in col4.

How can I make this possible? My query should not look for col4 unless I provide xxxxxx or yyyyyy in the query..

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions