Php/database/tables in html

I have a database for which i created html table code to display the data. next to each row of data i inserted a button for the user to select a row. BUT when the user clicks on select the session that displays the table data on the next page does not display the data for which the user clicked the button for, rather, it selects the last row of the table and displays that.

How can i make the selected row be displayed on the next page rather than the last row?

my code:

[php]
while($array = $sth->fetch(PDO::FETCH_ASSOC)){

$aircraftmodel2 = $array['model'];
$flightcode2 = $array['flightCode'];
$time2 = $array['departureTime'];
$price2 = $array['Price'];

$_SESSION[‘aircraft2’] = $aircraftmodel2;
$_SESSION[‘flightcode2’] = $flightcode2;
$_SESSION[‘time2’] = $time2;
$_SESSION[‘price2’] = $price2;

echo "<tr bgcolor = '#D8D8D8'><td><center>".$array['origin']."</center></td>
<td><center>".$array['destination']."</center></td>
<td><center>".$array['model']."</center></td>
<td><center>".$array['daydesc']."</center></td>
<td><center>".$array['flightCode']."</center></td>
<td><center>".$array['departureTime']."</center></td>
<td><center>$".$array['Price']."</center></td>
<td><center>".$array['capacity']."</center></td>
<td><center><button type='submit' class='button1'>Select</button></center></td></tr>";
												
}

[/php]

please reply asap :slight_smile:

I don’t see an actual form. Barring that, have a hidden field in the row containing the unique identifier for that row. Then the submit button *should pickup the post data and know which row to display.

Sponsor our Newsletter | Privacy Policy | Terms of Service