Walrus :
include 'config.php';
$location_null = "";
$location = "%{test}%";
$stmt = $conn->prepare('SELECT * FROM students WHERE location LIKE ? AND location = ?');
$stmt->bind_param('ss', $location, $location_null);
$stmt->execute();
This is my mysql codes. I wanna fetch datas from database for location like session and equal variable but this way's not working.
mrodo :
You have to replace the AND
with an OR
in your query to make both conditions work:
$stmt = $conn->prepare('SELECT * FROM students WHERE location LIKE ? OR location = ?');