我有一个表,其中包含从数据库加载的数据,并且每个行对应一个按钮。在按钮上单击,我希望存储在列之一中的数据存储在会话变量中,以便我可以在另一页中使用它
<?php
$con = mysqli_connect("localhost:3306","root","","travels");
session_start();
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$air1=$_POST['air'];
$source=$_POST['source'];
$dest=$_POST['destination'];
$sql1="SELECT flight_code,from_source,to_dest,arrival_time,departure_time,date_of_flight from flight_info INNER JOIN
airline_info on flight_info.a_code=airline_info.a_code and flight_info.from_source='$source' and
flight_info.to_dest='$dest' and airline_info.a_name='$air1' and flight_info.date_of_flight> CURDATE() and flight_info.seats_available>0;";
$result=mysqli_query($con,$sql1);
if($source==$dest)
{
header('Location: Error.html');
}
else if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td width=15%>" . $row['flight_code'] . "</td>";
echo "<td width=20%>" . $row['from_source'] . "</td>";
echo "<td width=20%>" . $row['to_dest'] . "</td>";
echo "<td width=20%>" . $row['departure_time'] . "</td>";
echo "<td width=15%>" . $row['arrival_time'] . "</td>";
echo "<td width=10%>" . $row['date_of_flight'] . "</td>";
echo "<form action='Booking.html' method='post'> ";
echo "<td width=15%><button type='submit' name='submit' class='btn btn-primary'>Book</button></td>";
echo "</form>";
echo "</tr>";
}
echo "</table>";
}
else
{
$_SESSION['source']=$source;
$_SESSION['dest']=$dest;
header('Location:Flight-unavailable.php');
}
?>
任何帮助,将不胜感激