LIKE query not working, it just output blank.
$stmt = $dbo->prepare("SELECT * FROM hotels WHERE h_country=:c LIKE '%m%'");
$stmt->bindValue(":c", "malaysia", PDO::PARAM_STR);
$stmt->execute();
LIKE query not working, it just output blank.
$stmt = $dbo->prepare("SELECT * FROM hotels WHERE h_country=:c LIKE '%m%'");
$stmt->bindValue(":c", "malaysia", PDO::PARAM_STR);
$stmt->execute();
Your SQL-Syntax is wrong, not sure what you want to obtain, but correct would be:
SELECT * FROM hotels WHERE h_country LIKE '%' || :c || '%';
--OR
SELECT * FROM hotels WHERE h_country = :c AND <your_column_here> LIKE '%m%';
Change
$stmt = $dbo->prepare("SELECT * FROM hotels WHERE h_country=:c LIKE '%m%'");
to
$stmt = $dbo->prepare("SELECT * FROM hotels WHERE h_country LIKE '%m%'");
You are either comparing values with the LIKE function or comparing with the variable ':c'. Its one or the other.
If you want to use both change to:
$stmt = $dbo->prepare("SELECT * FROM hotels WHERE h_country=:c OR h_country LIKE '%m%'");