uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

site.php (1877B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 	<meta charset="UTF-8">
      5 	<title>Insurance Covers</title>
      6 </head>
      7 
      8 <body>
      9 <?php
     10 	class insur_db extends SQLite3 {
     11 		function __construct() {
     12 			$this->open("insurance.db");
     13 		}
     14 	}
     15 	$db = new insur_db();
     16 
     17 ?>
     18 	<h2>Step 9</h2>
     19 	<table border="solid">
     20 	<tr>
     21 		<th>Cover Number</th>
     22 		<th>Description</th>
     23 		<th>Yearly Cost</th>
     24 		<th>Minimum Valid Months</th>
     25 	</tr>
     26 <?php
     27 
     28 	$res = $db->query("SELECT * FROM insurance_covers");
     29 	while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
     30 		echo "<tr>";
     31 		echo "<td>" . $row['cover_no'] . "</td>";
     32 		echo "<td>" . $row['desc'] . "</td>";
     33 		echo "<td>" . $row['yearly_cost'] . "</td>";
     34 		echo "<td>" . $row['min_valid_months'] . "</td>";
     35 		echo "</tr>";
     36 	}
     37 ?>
     38 	</table>
     39 
     40 	<hr>
     41 	<h2>Step 10</h2>
     42 	<p><form method="post">
     43 	<select name="product">
     44 		<option value=""></option>
     45 <?php
     46 	while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
     47 		echo "<option value=\"" . $row['cover_no'] . "\">" .
     48 		    $row['desc'] . "</option>";
     49 	}
     50 ?>
     51 	</select>
     52 	<input type="submit" name="submit"/>
     53 	</form></p>
     54 
     55 	<table border="solid">
     56 	<tr>
     57 		<th>Full Name</th>
     58 		<th>Address</th>
     59 		<th>Phone Number</th>
     60 		<th>VAT Number</th>
     61 		<th>Tax Office</th>
     62 	</tr>
     63 <?php
     64 	if (isset($_POST['submit'], $_POST['product']) && $_POST['product'] != "") {
     65 		$res = $db->query("
     66 			SELECT DISTINCT full_name, address, tel, vat_no, tax_office
     67 			FROM customers
     68 			INNER JOIN contracts USING(vat_no)
     69 			INNER JOIN insurance_covers USING(cover_no)
     70 			WHERE cover_no = " . $_POST['product']);
     71 
     72 		while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
     73 			echo "<tr>";
     74 			echo "<td>" . $row['full_name'] . "</td>";
     75 			echo "<td>" . $row['address'] . "</td>";
     76 			echo "<td>" . $row['tel'] . "</td>";
     77 			echo "<td>" . $row['vat_no'] . "</td>";
     78 			echo "<td>" . $row['tax_office'] . "</td>";
     79 			echo "</tr>";
     80 		}
     81 	}
     82 ?>
     83 	</table>
     84 <?php
     85 	$db->close();
     86 ?>
     87 </body>
     88 </html>