Advertisement
Guest User

Untitled

a guest
May 10th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <meta name="robots" content="noindex, nofollow" />
  6. <title>Details Task</title>
  7. <style type="text/css">
  8. body {
  9. font-family: "Arial", Times, serif;
  10. background-color: #D6D6D6;
  11. }
  12. .center {
  13. text-align:center;
  14. }
  15. body,td,th {
  16. color: #06F;
  17. }
  18. .larger {
  19. font-size:larger;
  20. text-align:right;
  21. }
  22. table {
  23. text-align: center;
  24. margin-left: auto;
  25. margin-right:auto;
  26.  
  27. }
  28.  
  29.  
  30. </style>
  31. </head>
  32. <body>
  33.  
  34. <div id="intro">
  35. <h1 class= "center"> Wedding Planner </h1>
  36.  
  37. </div>
  38.  
  39. <table border="1" id="valuestable">
  40. <form action="wedding.php" method="get" >
  41.  
  42.  
  43. <tr> <td> Party size:
  44. <input type= "text" name="size" id="size" value= "100" > </td>
  45. <td> Catering grade
  46. <input type="text" name="catering" id="catering" value="5" > </td> </tr>
  47. <tr> <td> Starting Date:
  48. <input type= "text" name="date1" id="date1" value="24/05/2016" > </td>
  49. <td> Ending Date
  50. <input type="text" name="date2" id="date2" value="25/05/2016" > </td> </tr>
  51.  
  52. <td><input type="submit" name="submit" id="submit" value="Submit" class="larger" /></td>
  53.  
  54. </form>
  55. </table>
  56.  
  57. <div id="sizediv">
  58. lufbra boys
  59. </div>
  60.  
  61. <div id="date">
  62. </div>
  63.  
  64. <div id="catering">
  65. </div>
  66.  
  67.  
  68. <script src= "jquery.js"> </script>
  69.  
  70.  
  71. <script>
  72. $(document).ready(function() {
  73.  
  74. $("#submit").on('click', function() {
  75.  
  76. $("#sizediv").html('my panel boy');
  77. })
  78. });
  79.  
  80. </script>
  81.  
  82.  
  83. <?php
  84. require_once 'MDB2.php';
  85.  
  86. $username= 'coa123wuser';
  87. $password= 'grt64dkh';
  88.  
  89. //define $host and $dbName
  90. $host='co-project.lboro.ac.uk';
  91. $dbName='coa123wdb';
  92.  
  93. // make connection to the server
  94. $dsn = "mysql://$username:$password@$host/$dbName";
  95. $db =& MDB2::connect($dsn);
  96.  
  97. if (PEAR::isError($db)) {
  98. # alert for errors or use global error handler
  99. die($db->getMessage());
  100. }
  101.  
  102. //Variable takes value of form on html file
  103.  
  104. if(isset($_REQUEST['submit'])) {
  105.  
  106. $val1= $_REQUEST['size'] ;
  107. $val2= $_REQUEST['date1'];
  108. $val3= $_REQUEST['date2'];
  109. $val4= $_REQUEST['catering'];
  110.  
  111. $date1 = date('Y-m-d', strtotime(str_replace('/', '-', $val2)));
  112. $date2 = date('Y-m-d', strtotime(str_replace('/', '-', $val3)));
  113.  
  114.  
  115. //Creation of a sql query
  116. $sql= "SELECT * FROM venue LEFT JOIN
  117. (SELECT * FROM venue_booking
  118. WHERE date_booked BETWEEN '". $date1 . "' AND '". $date2 ."') ta
  119. ON ta.venue_id = venue.venue_id
  120. WHERE ta.venue_id IS NULL AND Capacity >= ". $val1. " AND venue.venue_id IN
  121. (SELECT venue_id FROM catering
  122. WHERE grade = ". $val4.")";
  123.  
  124. $res =& $db->query($sql);
  125.  
  126. if(PEAR::isError($res)){
  127. die($res->getMessage());
  128. }
  129.  
  130. //Create array with name of table sections
  131. $tableName=array( "Venue Name","Capacity","Weekend Price","Weekday price");
  132.  
  133. //display relevent information (e.g. country_name list) using fetchRow s
  134.  
  135. echo "<table border='1'> </br> ";
  136. echo "<tr> <th>". $tableName[0]." </th> <th>" .$tableName[1]." </th> <th>" .$tableName[2]." </th> <th>" .$tableName[3]." </th> </tr>";
  137.  
  138. while ($row = $res->fetchRow()) {
  139. echo '<tr> <td>'.$row[1] .'</td> <td>'. $row[2].' </td> <td>'. $row[3].' </td> <td>'. $row[4].' </td> <tr>' ;
  140.  
  141. }
  142. echo "</table>";
  143.  
  144. }
  145.  
  146. else echo "Please enter all fields ";
  147.  
  148. ?>
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. </body>
  161. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement