How can PHP be used to display a table showing the frequency of attendance of conference guests?
To display a table showing the frequency of attendance of conference guests using PHP, you can create an associative array where the keys are the guest names and the values are the frequencies of their attendance. Then, you can loop through this array to generate a table with the guest names and their attendance frequencies.
<?php
// Sample array of guest attendance
$attendance = array(
'John' => 3,
'Jane' => 2,
'Alice' => 4,
'Bob' => 1
);
// Create a table to display the guest names and their attendance frequencies
echo '<table border="1">';
echo '<tr><th>Guest Name</th><th>Attendance Frequency</th></tr>';
foreach ($attendance as $guest => $frequency) {
echo '<tr><td>' . $guest . '</td><td>' . $frequency . '</td></tr>';
}
echo '</table>';
?>
Keywords
Related Questions
- How can the code provided be improved to efficiently count database entries in PHP?
- What are the potential benefits of centralizing title elements in PHP scripts, and how can this be achieved using conditional statements?
- What are some best practices for handling file existence checks on external resources in PHP?