Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="robots" content="noindex, nofollow" />
- <title>Details Task</title>
- <style type="text/css">
- body {
- font-family: "Arial", Times, serif;
- background-color: #D6D6D6;
- }
- .center {
- text-align:center;
- }
- body,td,th {
- color: #06F;
- }
- .larger {
- font-size:larger;
- text-align:right;
- }
- table {
- text-align: center;
- margin-left: auto;
- margin-right:auto;
- }
- </style>
- </head>
- <body>
- <div id="intro">
- <h1 class= "center"> Wedding Planner </h1>
- </div>
- <table border="1" id="valuestable">
- <form action="wedding.php" method="get" >
- <tr> <td> Party size:
- <input type= "text" name="size" id="size" value= "100" > </td>
- <td> Catering grade
- <input type="text" name="catering" id="catering" value="5" > </td> </tr>
- <tr> <td> Starting Date:
- <input type= "text" name="date1" id="date1" value="24/05/2016" > </td>
- <td> Ending Date
- <input type="text" name="date2" id="date2" value="25/05/2016" > </td> </tr>
- <td><input type="submit" name="submit" id="submit" value="Submit" class="larger" /></td>
- </form>
- </table>
- <div id="sizediv">
- lufbra boys
- </div>
- <div id="date">
- </div>
- <div id="catering">
- </div>
- <script src= "jquery.js"> </script>
- <script>
- $(document).ready(function() {
- $("#submit").on('click', function() {
- $("#sizediv").html('my panel boy');
- })
- });
- </script>
- <?php
- require_once 'MDB2.php';
- $username= 'coa123wuser';
- $password= 'grt64dkh';
- //define $host and $dbName
- $host='co-project.lboro.ac.uk';
- $dbName='coa123wdb';
- // make connection to the server
- $dsn = "mysql://$username:$password@$host/$dbName";
- $db =& MDB2::connect($dsn);
- if (PEAR::isError($db)) {
- # alert for errors or use global error handler
- die($db->getMessage());
- }
- //Variable takes value of form on html file
- if(isset($_REQUEST['submit'])) {
- $val1= $_REQUEST['size'] ;
- $val2= $_REQUEST['date1'];
- $val3= $_REQUEST['date2'];
- $val4= $_REQUEST['catering'];
- $date1 = date('Y-m-d', strtotime(str_replace('/', '-', $val2)));
- $date2 = date('Y-m-d', strtotime(str_replace('/', '-', $val3)));
- //Creation of a sql query
- $sql= "SELECT * FROM venue LEFT JOIN
- (SELECT * FROM venue_booking
- WHERE date_booked BETWEEN '". $date1 . "' AND '". $date2 ."') ta
- ON ta.venue_id = venue.venue_id
- WHERE ta.venue_id IS NULL AND Capacity >= ". $val1. " AND venue.venue_id IN
- (SELECT venue_id FROM catering
- WHERE grade = ". $val4.")";
- $res =& $db->query($sql);
- if(PEAR::isError($res)){
- die($res->getMessage());
- }
- //Create array with name of table sections
- $tableName=array( "Venue Name","Capacity","Weekend Price","Weekday price");
- //display relevent information (e.g. country_name list) using fetchRow s
- echo "<table border='1'> </br> ";
- echo "<tr> <th>". $tableName[0]." </th> <th>" .$tableName[1]." </th> <th>" .$tableName[2]." </th> <th>" .$tableName[3]." </th> </tr>";
- while ($row = $res->fetchRow()) {
- echo '<tr> <td>'.$row[1] .'</td> <td>'. $row[2].' </td> <td>'. $row[3].' </td> <td>'. $row[4].' </td> <tr>' ;
- }
- echo "</table>";
- }
- else echo "Please enter all fields ";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement