Advertisement
Guest User

Untitled

a guest
May 4th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.24 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Achmed! - search</title>
  4.     </head>
  5.     <body>
  6.         <h1>Hederlige Achmeds Kamel och Bostadshandel</h1>
  7.         <?php
  8.         //phpinfo();
  9.         $link = pg_connect("host=pgsql0 dbname=jlaurin user=jlaurin password=secret");
  10.         $result = pg_exec($link, "select * from bostader");
  11.         $numrows = pg_numrows($result);
  12.         $lanarray = array();
  13.         $typarray = array();
  14.         $rumarray = array();
  15.  
  16.         for ($i = 0; $i < $numrows; $i++) {
  17.             $disrow = pg_fetch_array($result, $i);
  18.             if (!in_array($disrow["lan"],$lanarray)) {
  19.                 array_push($lanarray, $disrow["lan"]);
  20.             }
  21.             if (!in_array($disrow["objekttyp"],$typarray)) {
  22.                 array_push($typarray, $disrow["objekttyp"]);
  23.             }
  24.             if (!in_array($disrow["rum"],$rumarray)) {
  25.                 array_push($rumarray, $disrow["rum"]);
  26.             }
  27.  
  28.         }
  29.         pg_close($link);
  30.         ?>
  31.  
  32.         <form name="bostadsform" action="result.php" method="get">
  33.             <!-- <input type="hidden" name="sort" value="lan"/> -->
  34.             <?php
  35.             echo "<input type =\"hidden\" name=\"numtyper\" value=\"",count($typarray),"\"/>";
  36.             ?>
  37.             <table border="1">
  38.                 <tr>
  39.                     <th>LÄN!</th>
  40.                     <th>BOSTADSTYP!</th>
  41.                     <th>ANTAL RUM DU SKA HA!</th>
  42.                 </tr>
  43.                 <tr>
  44.                     <td>
  45.                         <?php
  46.                         echo "<table border=\"0\">\n";
  47.  
  48.                         for ($i = 0; $i < count($lanarray); $i++) {
  49.                             echo "<tr>\n";
  50.                             echo "<td> <input type = \"checkbox\" name = \"lan",$i,"\" value = \"",$lanarray[$i],"\"/> ",$lanarray[$i],"</td>\n";
  51.                             echo "</tr>\n";
  52.                         }
  53.                         echo "</table>\n";
  54.  
  55.                         ?>
  56.  
  57.                     </td>
  58.                     <td>
  59.                         <?php
  60.                         echo "<table border=\"0\">\n";
  61.  
  62.                         for ($i = 0; $i < count($typarray); $i++) {
  63.                             echo "<tr>\n";
  64.                             echo "<td> <input type = \"checkbox\" name = \"typ",$i,"\" value = \"",$typarray[$i],"\"/> ",$typarray[$i],"</td>\n";
  65.                             echo "</tr>\n";
  66.                         }
  67.                         echo "</table>\n";
  68.  
  69.                         ?>
  70.  
  71.                     </td>
  72.                     <td>
  73.                         <?php
  74.                         echo "<table border=\"0\">\n";
  75.                        
  76.                         for ($i = 0; $i < count($rumarray); $i++) {
  77.                             echo "<tr>\n";
  78.                             echo "<td> <input type = \"checkbox\" name = \"rum",$i,"\" value = \"",$rumarray[$i],"\"/> ",$rumarray[$i],"</td>\n";
  79.                             echo "</tr>\n";
  80.                         }
  81.                         echo "</table>\n";  
  82.                         ?>
  83.                     </td>
  84.                 </tr>
  85.  
  86.             </table>
  87.             <input type="submit" value="Resuldoken!" />
  88.         </form>
  89.     </body>
  90. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement