Advertisement
NK14

PHP

Nov 27th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <?php include "head.php";?>
  4.     </head>
  5.     <body>
  6.     <?php include "navBar.php";?>
  7.         <form action="addPrato.php" method="post">
  8.                 <h3>Escolha ID do Leilão a concorrer</h3>
  9.                 <p>Leilão:
  10.                 <select name="prato_alimento">
  11.                     <?php
  12.                         try{
  13.                             $host = "db.ist.utl.pt";
  14.                             $user ="ist166983";
  15.                             $password = "rrdu5980";
  16.                             $dbname = $user;
  17.                             $db = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
  18.                             $sql = "SELECT l.nif, l.dia, l.nrleilaonodia  FROM leilao as l;";
  19.                             $result = $db->query($sql);
  20.                            
  21.                            
  22.                             foreach($result as $row){
  23.                                 //$alimento_name = $row['nif'];
  24.                                 $alimento_name = $row['nif'];
  25.                                 $alimento_name1 = $row['dia'];
  26.                                 $alimento_name2 = $row['nrleilaonodia '];
  27.                                 echo("<option value=\"$alimento_name\">$alimento_name</option>\n"+"<option value=\"$alimento_name1\">$alimento_name1</option>\n"+"<option value=\"$alimento_name2\">$alimento_name2</option>\n");
  28.                             }
  29.                            
  30.                             $db = null;
  31.                         }catch (PDOException $e){
  32.                             echo("<p>ERROR: {$e->getMessage()}<p/>");
  33.                         }
  34.                     ?>
  35.                 </select>
  36.             </p>
  37.             <p><input type="submit" value="Submit"/></p>
  38.         </form>
  39.     </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement