How do i display data from two tables while running the code below. I have a table called PASSENGERS and I would like to select a fname from that table and add it so as to display it also within output html table.I get and error Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\aero\view_booked_tickets.php on line 63 everytime i try to query two table.
<?php
session_start();
?>
<html>
<head>
<title>
View Booked Tickets
</title>
<style>
input {
border: 1.5px solid #030337;
border-radius: 4px;
padding: 7px 30px;
}
input[type=submit] {
background-color: #030337;
color: white;
border-radius: 4px;
padding: 7px 45px;
margin: 0px 390px
}
table {
border-collapse: collapse;
margin-left: 10%;
margin-right: 10%;
}
tr/*:nth-child(3)*/ {
border: solid thin;
}
.set_nice_size{
font-size: 17pt;
}
</style>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="stylesheet" href="font-awesome-4.7.0\css\font-awesome.min.css">
</head>
<body>
<img class="logo" src="images/shutterstock_22.jpg"/>
<h1 id="title">
AADITH AIRLINES
</h1>
<div>
<ul>
<li><a href="customer_homepage.php"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
<li><a href="customer_homepage.php"><i class="fa fa-desktop" aria-hidden="true"></i> Dashboard</a></li>
<li><a href="home_page.php"><i class="fa fa-plane" aria-hidden="true"></i> About Us</a></li>
<li><a href="home_page.php"><i class="fa fa-phone" aria-hidden="true"></i> Contact Us</a></li>
<li><a href="logout_handler.php"><i class="fa fa-sign-out" aria-hidden="true"></i> Logout</a></li>
</ul>
</div>
<h2>VIEW BOOKED FLIGHT TICKETS</h2>
<h3 class='set_nice_size'><center><u>Upcoming Trips</u></center></h3>
<?php
$todays_date=date('Y-m-d');
$thirty_days_before_date=date_create(date('Y-m-d'));
date_sub($thirty_days_before_date,date_interval_create_from_date_string("30 days"));
$thirty_days_before_date=date_format($thirty_days_before_date,"Y-m-d");
$customer_id=$_SESSION['login_user'];
require_once('Database Connection file/mysqli_connect.php');
$query="SELECT pnr,date_of_reservation,flight_no,journey_date,class,booking_status,no_of_passengers,payment_id FROM Ticket_Details where customer_id=? AND journey_date>=? AND booking_status='CONFIRMED' ORDER BY journey_date";
$stmt=mysqli_prepare($dbc,$query);
mysqli_stmt_bind_param($stmt,"ss",$customer_id,$todays_date);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$pnr,$date_of_reservation,$flight_no,$journey_date,$class,$booking_status,$no_of_passengers,$payment_id);
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt)==0)
{
echo "<h3><center>No upcoming trips!</center></h3>";
}
else
{
echo "<table cellpadding=\"10\"";
echo "<tr><th>PNR</th>
<th>Date of Reservation</th>
<th>Flight No.</th>
<th>Journey Date</th>
<th>Class</th>
<th>Booking Status</th>
<th>No. of Passengers</th>
<th>Payment ID</th>
</tr>";
while(mysqli_stmt_fetch($stmt)) {
echo "<tr>
<td>".$pnr."</td>
<td>".$date_of_reservation."</td>
<td>".$flight_no."</td>
<td>".$journey_date."</td>
<td>".$class."</td>
<td>".$booking_status."</td>
<td>".$no_of_passengers."</td>
<td>".$payment_id."</td>
</tr>";
}
echo "</table> <br>";
}
echo "<br><h3 class=\"set_nice_size\"><center><u>Completed Trips</u></center></h3>";
$query="SELECT pnr,date_of_reservation,flight_no,journey_date,class,booking_status,no_of_passengers,payment_id FROM Ticket_Details where customer_id=? and journey_date<? and journey_date>=? ORDER BY journey_date";
$stmt=mysqli_prepare($dbc,$query);
mysqli_stmt_bind_param($stmt,"sss",$customer_id,$todays_date,$thirty_days_before_date);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$pnr,$date_of_reservation,$flight_no,$journey_date,$class,$booking_status,$no_of_passengers,$payment_id);
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt)==0)
{
echo "<h3><center>No trips completed in the past 30 days!</center></h3>";
}
else
{
echo "<table cellpadding=\"10\"";
echo "<tr><th>PNR</th>
<th>Date of Reservation</th>
<th>Flight No.</th>
<th>Journey Date</th>
<th>Class</th>
<th>Booking Status</th>
<th>No. of Passengers</th>
<th>Payment ID</th>
</tr>";
while(mysqli_stmt_fetch($stmt)) {
echo "<tr>
<td>".$pnr."</td>
<td>".$date_of_reservation."</td>
<td>".$flight_no."</td>
<td>".$journey_date."</td>
<td>".$class."</td>
<td>".$booking_status."</td>
<td>".$no_of_passengers."</td>
<td>".$payment_id."</td>
</tr>";
}
echo "</table> <br>";
}
mysqli_stmt_close($stmt);
mysqli_close($dbc);
?>
</body>
</html>