Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4.     <title>Pagina</title>
  5. </head>
  6. <body>
  7.  
  8.     <div align="center">
  9.     <h1>Prova connessione</h1>
  10.     <table width="200" border="1">
  11.     <tr>
  12.     <th>Matricola</th>
  13.     <th>Nome</th>
  14.     <th>Cognome</th>
  15.     <th>Cod. fiscale</th>
  16.     <th>Telefono</th>
  17.     </tr>  
  18.     <?php
  19.         $cognome = $_POST['cognome'];
  20.         $host = "127.0.0.1";
  21.         $user="hello";
  22.         $password = "malafarina";
  23.         $db = "hello";
  24.         $table = "Studenti";
  25.         mysql_connect($host, $user, $password) or die ("Connessione non riuscita ".mysql_error());
  26.         mysql_select_db($db) or die ("Database inesistente".mysql_error());
  27.         $sql_query = "SELECT * FROM $table WHERE Cognome = \"".$cognome."\";";
  28.         $risultato = mysql_query($sql_query);
  29.         while($riga = mysql_fetch_array($risultato))
  30.         {
  31.             print "<tr>\n";
  32.             print "<td>".$riga['Matricola']."</td>\n";
  33.             print "<td>".$riga['Nome']."</td>\n";
  34.             print "<td>".$riga['Cognome']."</td>\n";
  35.             print "<td>".$riga['CodFiscale']."</td>\n";
  36.             print "<td>".$riga['Telefono']."</td>\n";
  37.             print "</tr>\n    ";
  38.         }
  39.     ?>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement