What adjustments can be made to the printTicketType function to display a table instead of a select box?
To display a table instead of a select box in the printTicketType function, we need to modify the HTML output generated by the function. We can create a table with rows and columns to display the ticket types along with their details. Each row in the table will represent a ticket type with its corresponding information.
function printTicketType() {
// Retrieve ticket types from the database or any data source
$ticketTypes = array(
array('name' => 'General Admission', 'price' => '$20'),
array('name' => 'VIP', 'price' => '$50'),
array('name' => 'Student', 'price' => '$15')
);
echo '<table>';
echo '<tr><th>Ticket Type</th><th>Price</th></tr>';
foreach ($ticketTypes as $ticket) {
echo '<tr>';
echo '<td>' . $ticket['name'] . '</td>';
echo '<td>' . $ticket['price'] . '</td>';
echo '</tr>';
}
echo '</table>';
}
// Call the function to display ticket types in a table format
printTicketType();
Keywords
Related Questions
- What steps can be taken to ensure that data integrity is maintained when dealing with UNIQUE constraints and duplicate entries in PHP and MySQL databases?
- How can the functionality of marking and deleting table entries with checkboxes be optimized for performance in PHP?
- How can functions in PHP be structured to handle input validation and account creation separately for better code organization?