event1.html Event: PHP Social Brunch Date: Sat 02 Jan 2016 Venue: The Coffee Shot |
event2.html Event: Singapore PHP User Group Meetup (Jan 2016) Date: Mon 11 Jan 2016 Venue: PayPal Singapore |
event.php?id=1 Event: PHP Social Brunch Date: Sat 02 Jan 2016 Venue: The Coffee Shot |
event.php?id=2 Event: Singapore PHP User Group Meetup (Jan 2016) Date: Mon 11 Jan 2016 Venue: PayPal Singapore |
<?php /* event.php */
$conn = new mysqli('localhost', 'username', 'password'); // Database connection
if (!$conn) { die('Connection failed: ' . mysqli_connect_error()); }
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$result = $id ? $conn->query("SELECT * FROM events WHERE id='{$id}'") : false;
if ($result !== false && $result->num_rows > 0) {
$event = $result->fetch_object();
printf(
'Event: %s<br>Date: %s<br>Venue: %s',
$event->name,
$event->date,
$event->venue
);
}
event_id-1.php Event: PHP Social Brunch Date: Sat 02 Jan 2016 Venue: The Coffee Shot |
event_id-2.php Event: Singapore PHP User Group Meetup (Jan 2016) Date: Mon 11 Jan 2016 Venue: PayPal Singapore |