Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Write a PHP script InformationTable.php which generates an HTML table by given information about a person
- (name, phone number, age, address). Styling the table is optional. Semantic HTML is required.-->
- <!DOCTYPE html>
- <html>
- <head lang="en">
- <meta content="text/html" charset="UTF-8">
- <title>HTML Table</title>
- <style type="text/css">
- table {
- border-collapse: collapse;
- }
- td {
- padding: 5px;
- border: 1px solid #000;
- }
- td:first-child {
- background-color: orange;
- //font-weight: 600;
- }
- td:last-child {
- text-align: right;
- }
- </style>
- </head>
- <body>
- <?php
- function generateHTMLTable($personalData = array('name', 'phoneNumber', 'age', 'address')) {
- echo '<table><tbody>';
- for ($i = 0; $i < count($personalData); $i++) {
- $currentRow = '<tr><td><strong>';
- switch ($i) {
- case 0:
- $currentRow .= 'Name';
- break;
- case 1:
- $currentRow .= 'Phone Number';
- break;
- case 2:
- $currentRow .= 'Age';
- break;
- case 3:
- $currentRow .= 'Address';
- break;
- }
- echo "$currentRow</strong></td><td>$personalData[$i]</td></tr>";
- }
- echo '</tbody></table>';
- }
- generateHTMLTable(array('Gosho', '0882-321-423', 24, 'Hadji Dimitar'));
- generateHTMLTable(array('Pesho', '0884-888-888', '67', 'Suhata Reka'));
- generateHTMLTable();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement