Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. <?php
  2. $host="localhost:3306";
  3. $user='root';
  4. $password="";
  5. $dbname="Transport_aerien";
  6.  
  7.  
  8. $connect = @mysql_connect($host, $user, $password); // connexion à l'administrateur en entrant un user et un pswd//
  9. if ( $connect == true) // si la connexion est établie//
  10. echo "Connexion reussie<br><br>";
  11. else echo "Connexion non établie <br><br>"; // sinon la connexion est non établie //
  12.  
  13. $select_db = @mysql_select_db($dbname,$connect); // déclaration de la selection de la base de données //
  14. if ( $select_db == true) // si la connexion est établie//
  15. echo "select_db ok<br><br>";
  16. else echo "select_db erreur<br><br>"; // sinon la connexion est non établie //
  17.  
  18.  
  19.  
  20.  
  21.  
  22. $reponse = @mysql_query('SELECT PLNUM,PLNOM FROM pilote'); // réponse de la requête sql //
  23. if ( $reponse == false) // si la base de données correspond à dbname //
  24. echo "erreur mysql_query<br><br>";
  25. else echo "mysql_query ok<br><br>"; // sinon la connexion est non établie //
  26.  
  27. $N = @mysql_num_fields($reponse);
  28. echo "$N colonnes<br><br>";
  29. //$col0 = @mysql_field_name($reponse , 0);
  30. //echo "colonne n°0 = $col0<br><br>";
  31. $ligne = mysql_fetch_array($reponse );
  32.  
  33. echo "<table border=1> <tr>";
  34.  
  35. for ($i=0; $i<$N; $i++) echo "<th>". mysql_field_name ($reponse,$i) . "</th>";
  36. echo "</tr>";
  37.  
  38.  
  39. while ( ($ligne = mysql_fetch_array($reponse)) != false ){
  40. echo "<tr>";
  41. for ($i=0; $i<$N; $i++) echo "<td>$ligne[$i]</td>";
  42. echo "</tr>";
  43. }
  44. echo "</table>";
  45.  
  46.  
  47. //-----------------------------------------------------------------------------------------------
  48. $reponse = @mysql_query('SELECT * FROM pilote'); // réponse de la requête sql //
  49. if ( $reponse == false) // si la base de données correspond à dbname //
  50. echo "erreur mysql_query<br><br>";
  51. else echo "mysql_query ok<br><br>"; // sinon la connexion est non établie //
  52.  
  53. $N = @mysql_num_fields($reponse);
  54. echo "$N colonnes<br><br>";
  55. //$col0 = @mysql_field_name($reponse , 0);
  56. //echo "colonne n°0 = $col0<br><br>";
  57. $ligne = mysql_fetch_array($reponse );
  58.  
  59. echo "<table border=1> <tr>";
  60.  
  61. for ($i=0; $i<$N; $i++) echo "<th>". mysql_field_name ($reponse,$i) . "</th>";
  62. echo "</tr>";
  63.  
  64.  
  65. while ( ($ligne = mysql_fetch_array($reponse)) != false ){
  66. echo "<tr>";
  67. for ($i=0; $i<$N; $i++) echo "<td>$ligne[$i]</td>";
  68. echo "</tr>";
  69. }
  70. echo "</table>";
  71.  
  72. //---------------------------------------------------------------------------------------------
  73.  
  74. $reponse = @mysql_query(' SELECT DISTINCT * FROM pilote, vol WHERE (pilote.PLNUM = vol.PLNUM) '); // réponse de la requête sql //
  75. if ( $reponse == false) // si la base de données correspond à dbname //
  76. echo "erreur mysql_query<br><br>";
  77. else echo "mysql_query ok<br><br>"; // sinon la connexion est non établie //
  78.  
  79. $N = @mysql_num_fields($reponse);
  80. echo "$N colonnes<br><br>";
  81. //$col0 = @mysql_field_name($reponse , 0);
  82. //echo "colonne n°0 = $col0<br><br>";
  83. $ligne = mysql_fetch_array($reponse );
  84.  
  85. echo "<table border=1> <tr>";
  86.  
  87. for ($i=0; $i<$N; $i++) echo "<th>". mysql_field_name ($reponse,$i) . "</th>";
  88. echo "</tr>";
  89.  
  90.  
  91. while ( ($ligne = mysql_fetch_array($reponse)) != false ){
  92. echo "<tr>";
  93. for ($i=0; $i<$N; $i++) echo "<td>$ligne[$i]</td>";
  94. echo "</tr>";
  95. }
  96. echo "</table>";
  97.  
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement