Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- echo"<body bgcolor=#FFFFCC>";
- $host ="localhost:3306";
- $user ="root";
- $password ="";
- $dbname ="transport_aerien";
- echo '<div style="color: blue; font-family: arial; font-size: 10px;">';
- $req1 = 'SELECT PLNUM,PLNOM FROM PILOTE';
- $rep = connexion($req1);
- tab_out($rep);
- $req2 = 'SELECT DISTINCT * FROM PILOTE WHERE (SALAIRE >= 18000)';
- $rep = connexion($req1);
- tab_out($rep);
- $req3 = 'SELECT DISTINCT * FROM PILOTE, VOL WHERE (PILOTE.PLNUM = VOL.PLNUM)';
- $rep = connexion($req1);
- tab_out($rep);
- echo'</div>';
- function connexion($req) {
- $host ="localhost:3306";
- $user ="root";
- $password ="";
- $dbname ="transport_aerien";
- $connect = @mysql_connect($host, $user, $password); // @ n'affiche pas les erreurs de la fonction
- if (!$connect) { die('Impossible de se connecter : ' . mysql_error()); } else echo 'Connexion réussie <br/>';
- $db_selected = mysql_select_db($dbname, $connect);
- if (!$db_selected) { die ('Impossible de sélectionner la bd : ' . mysql_error()); } else echo 'Sélection BD réussie<br/>';
- echo "Requête : SELECT PLNUM,PLNOM FROM PILOTE :<br>";
- $reponse = mysql_query('SELECT PLNUM,PLNOM FROM PILOTE');
- mysql_close($connect);
- return $reponse;
- }
- function tab_out($result) {
- $N = mysql_num_fields($result); // N = nombre de colonnes du tableau $result
- printf("<table border='0' cellpadding='1' cellspacing='1' style='font-family: arial; font-size: 10px;'>");
- printf("<tr style='color: black;' bgcolor=#D0D0D0>");
- for ($i=0; $i<$N; $i++) printf("<th>%s</th>", mysql_field_name($result,$i));
- echo "</tr>";
- while ( $ligne = mysql_fetch_array( $result, MYSQL_NUM ))
- { echo "<tr style='color: maroon;' bgcolor='#E8E8E8'>";
- for($n=0; $n<$N ; $n++) printf("<td>%s</td>", $ligne[$n]);
- echo "</tr>";
- }
- echo "</table>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement