<?php $txt = "W3Schools.com"; echo "I love " . $txt . "!"; ?> <?php //php two rows of data $invoices = array ( array ( "invoice_id" => "16" , "vendor_id" => "97" , "invoice_number" => "21-4748363" , "invoice_date"=> "2014-05-03"), array ( "invoice_id" => "23" , "vendor_id" => "97" , "invoice_number" => "21-4923721" , "invoice_date"=> "2014-05-13") ); function outputInvoice($invoice) { echo '<tr>'; echo '<td>' . $invoice['invoice_id']. '</td>'; echo '<td>' . $invoice['vendor_id'] .'</td>'; echo '<td>' . $invoice['invoice_number'] .'</td>'; echo '<td>' . $invoice['invoice_date'].'</td>'; echo '</tr>'; } ?> <!DOCTYPE html> <html> <!-- the head section --> <head> <title>Account Payable Database System</title> </head> <!-- the body section --> <body> <div id="wrapper"> <header><h1> ITS322 Client/Server Database </h1></header> <main> <h1>Invoices Table </h1> <table> <tr> <th>invoice_id</th> <th>vendor id</th> <th>invoice_number</th> <th>Invoice_date</th> </tr> <tbody> <!-- invoke a php function within a loop --> <?php foreach ($invoices as $invoice) { outputInvoice($invoice); } ?> </tbody> </table> </main> <footer>Copyright © Irene Tseng 2019</footer> </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more