Advertisement
jmillard

Untitled

Dec 3rd, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.20 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?php
  3. $connection = oci_connect($username = '******',
  4.                           $password = '******',
  5.                           $connection_string = '//oracle.cise.ufl.edu/orcl');
  6. $model = $_POST["model"];
  7. $make = $_POST["make"];
  8. $year = $_POST["year"];
  9. $HImpg = $_POST["HImpg"];
  10. $LOmpg = $_POST["LOmpg"];
  11. $transmission = $_POST["Transmission"];
  12. $HImiles = $_POST["HImiles"];
  13. $LOmiles = $_POST["LOmiles"];
  14. $HIincidents = $_POST["HIincidents"];
  15. $LOincidents = $_POST["LOincidents"];
  16. $HInumOwners = $_POST["HInumOwners"];
  17. $LOnumOwners = $_POST["LOnumOwners"];
  18. $HIcost = $_POST["HIcost"];
  19. $LOcost = $_POST["LOcost"];
  20. $color = $_POST["color"];
  21. $state = $_POST["state"];
  22. $region = $_POST["region"];
  23. $HIcondition = $_POST["HIcondition"];
  24. $LOcondition = $_POST["LOcondition"];
  25. $select = "SELECT * ";
  26. $from = "FROM vehicle ";
  27. $where = "WHERE";
  28. $count = 0;
  29. echo $HImpg."\n" ;
  30. echo $LOmpg;
  31. if($make!=""){
  32.         $where .= " make_name = '$make'";
  33.         $count+=1;
  34. }
  35. if($model!=""){
  36.         if($count>0){
  37.                 $where .= " AND";
  38.         }
  39.         $where .= " model_name = '$model'";
  40.         $count+=1;
  41. }if($transmission!=""){
  42.         if($count>0){
  43.                 $where .= " AND";
  44.         }
  45.         $where .= " TRANSMISSION  = '$transmission'";
  46.         $count+=1;
  47. }
  48. if($HImiles>$LOmiles){
  49.         if($count>0){
  50.                 $where .= " AND";
  51.         }
  52.         $where .= " MILES >= $LOmiles AND MILES <= $HImiles";
  53.         $count+=1;
  54. }
  55. if($HIincidents>$LOincidents){
  56.         if($count>0){
  57.                 $where .= " AND";
  58.         }
  59.         $where .= " INCIDENTS >= $LOincidents AND INCIDENTS <= $HIincidents";
  60.         $count+=1;
  61. }
  62. if($year!=""){
  63.         if($count>0){
  64.                 $where .= " AND";
  65.         }
  66.         $where .= " YEAR = $year";
  67.         $count+=1;
  68. }
  69. if($HImpg>$LOmpg){
  70.         if($count>0){
  71.                 $where .= " AND";
  72.         }
  73.         $where .= " MPG >= $LOmpg AND MPG <= $HImpg";
  74.         $count+=1;
  75. }
  76. if($color!=""){
  77.         if($count>0){
  78.                 $where .= " AND";
  79.         }
  80.         $where .= " color = '$color'";
  81.         $count+=1;
  82. }
  83. if($state!=""){
  84.         if($count>0){
  85.                 $where .= " AND";
  86.         }
  87.         $where .= " STATE = '$state'";
  88.         $count+=1;
  89. }
  90. if($HIcondition>$LOcondition){
  91.         if($count>0){
  92.                 $where .= " AND";
  93.         }
  94.         $where .= " CONDITION >= $LOcondition AND CONDITION <= $HIcondition";
  95.         $count+=1;
  96. }
  97. if($HInumOwners>$LOnumOwners){
  98.         if($count>0){
  99.                 $where .= " AND";
  100.         }
  101.         $where .= " NUMBER_OWNERS >= $LOnumOwners AND NUMBER_OWNERS <= $HInumOwners";
  102.         $count+=1;
  103. }
  104. if($HIcost>$LOcost){
  105.         if($count>0){
  106.                 $where .= " AND";
  107.         }
  108.         $where .= " COST >= $LOcost AND COST <= $HIcost";
  109.         $count+=1;
  110. }
  111. if($region!=""){
  112.         if($count>0){
  113.                 $where .= " AND";
  114.         }
  115.         $where .= " REGION = '$region'";
  116.         $count+=1;
  117. }
  118. $query = "{$select}{$from}{$where}";
  119. echo $query;
  120. /*else {
  121.   $query = "{$select}{$from}"select}{$from}{$where}";
  122.  
  123. }*/
  124.  
  125.  
  126. $statement = oci_parse($connection, $query);
  127. oci_execute($statement);
  128. print "<table border='1'>\n";
  129. while ($row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS)) {
  130.     print "<tr> \n";
  131.     echo "<td> <a href=details.php?VIN=$row[VIN]&MAN=$row[MAKE_NAME]&MON=$row[MODEL_NAME]&Y=$row[YEAR]&MPG=$row[MPG]&T=$row[TRANSMISSION]&C=$row[CONDITION]&MILES=$row[MILES]&I=$row[INCIDENTS]&NO=$row[NUMBER_OWNERS]&COST=$row[COST]&COLOR=$row[COLOR]&STATE=$row[STATE]&REGION=$row[REGION]>Details </a> </td>";
  132.     foreach ($row as $item) {
  133.         echo "    <td>" .($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . " </a></td>\n";
  134.     }
  135.     print " </tr>\n";
  136. }
  137. print "</table>\n";
  138.  
  139.  
  140.  
  141. $statement = oci_parse($connection, $query);
  142. oci_execute($statement);
  143.  
  144. /*
  145. while ($row = oci_fetch_array($statement) {
  146.     echo "hi";
  147.     //echo "<a href = "details.php">" .$row['VIN']"</a>";
  148. };
  149. */
  150.  
  151.  
  152. //
  153. // VERY important to close Oracle Database Connections and free statements!
  154. //
  155. oci_free_statement($statement);
  156. oci_close($connection);
  157. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement