Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?PHP
  2. echo"<body bgcolor=#FFFFCC>";
  3. $host ="localhost:3306";
  4. $user ="root";
  5. $password ="";
  6. $dbname ="transport_aerien";
  7. echo '<div style="color: blue; font-family: arial; font-size: 10px;">';
  8. $req1 = 'SELECT PLNUM,PLNOM FROM PILOTE';
  9. $rep = connexion($req1);
  10. tab_out($rep);
  11. $req2 = 'SELECT DISTINCT * FROM PILOTE WHERE (SALAIRE >= 18000)';
  12. $rep = connexion($req1);
  13. tab_out($rep);
  14. $req3 = 'SELECT DISTINCT * FROM PILOTE, VOL WHERE (PILOTE.PLNUM = VOL.PLNUM)';
  15. $rep = connexion($req1);
  16. tab_out($rep);
  17. echo'</div>';
  18.  
  19. function connexion($req) {
  20.  
  21. $host ="localhost:3306";
  22. $user ="root";
  23. $password ="";
  24. $dbname ="transport_aerien";
  25. $connect = @mysql_connect($host, $user, $password); // @ n'affiche pas les erreurs de la fonction
  26. if (!$connect) { die('Impossible de se connecter : ' . mysql_error()); } else echo 'Connexion réussie <br/>';
  27. $db_selected = mysql_select_db($dbname, $connect);
  28. if (!$db_selected) { die ('Impossible de sélectionner la bd : ' . mysql_error()); } else echo 'Sélection BD réussie<br/>';
  29. echo "Requête : SELECT PLNUM,PLNOM FROM PILOTE :<br>";
  30. $reponse = mysql_query('SELECT PLNUM,PLNOM FROM PILOTE');
  31. mysql_close($connect);
  32. return $reponse;
  33. }
  34. function tab_out($result) {
  35. $N = mysql_num_fields($result); // N = nombre de colonnes du tableau $result
  36. printf("<table border='0' cellpadding='1' cellspacing='1' style='font-family: arial; font-size: 10px;'>");
  37. printf("<tr style='color: black;' bgcolor=#D0D0D0>");
  38. for ($i=0; $i<$N; $i++) printf("<th>%s</th>", mysql_field_name($result,$i));
  39. echo "</tr>";
  40. while ( $ligne = mysql_fetch_array( $result, MYSQL_NUM ))
  41. { echo "<tr style='color: maroon;' bgcolor='#E8E8E8'>";
  42. for($n=0; $n<$N ; $n++) printf("<td>%s</td>", $ligne[$n]);
  43. echo "</tr>";
  44. }
  45. echo "</table>";
  46. }
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement