Reputation: 21
I want to make some kind of booking system. I am displaying all data about cars from the database with buttons(which is a link that directs to the booking page) in "boxes", each box is for one car. I want to get id of the car for which the user pressed the button in box where the car is.
Here is my code
<!-- Fetching data from rows -->
<?php
while($rows = $result->fetch_assoc())
{
?>
<div class="car_box">
<div class="car_title">
<p><b><?php echo $rows['Brand'],' ', $rows['Model'];?></b></p>
</div>
<div class="car_description">
<div class="car_details">
<!-- ENGINE CAPACITY -->
<p>
<b>Engine capacity: </b> <?php echo $rows['Engine_capacity']; ?> cm3
</p>
(...)
<!-- BOOKING -->
<div class="booking">
<a href="../Bookings.php" class="book_now_button">Book now</a>
</div>
</div>
Upvotes: 1
Views: 43
Reputation: 11
You could try adding a parameter to your link.
<a href="../Bookings.php?id=<?php echo $rows['id']; ?>" class="book_now_button">Book now</a>
and retrieve it in your Bookings.php by using $_GET['id']
.
Upvotes: 1