I'm currently working on a project where I'm creating a travel agency site using PHP
and MySQL
.
I've come across an issue where I want to add a search function that uses information from multiple SELECT
options such as airport, location and stay length of which the corresponding information is stored in their own relevant table within MySQL.
How do I querying the database using multiple tables? I've attempted the below solution by selecting each table and column within the table with no success.
$location = $_GET['location'];
$airport = $_GET['airport'];
$stay = $_GET['stay'];
$date = $_GET['date'];
$sql = "SELECT location_name, airport__name, stay_length FROM airport, location, stay WHERE location__name =?, airport_name =?, stay_length =?";
$result = mysqli_query($conn, $sql);
echo $result;
DB Name: Flight
Table Names: location, stay, airport
Columns
location = location_id, location_name
stay = stay_id, stay_length
airport = airport_id, airport_name