par
sbi016 » 14 oct. 2009, 19:42
Bonsoir Khan
Le fichier PHp qui tourne actuellement c'est celui que j'ai mis hier
de sbi016 le 14 Oct 2009, 07:31
Bonjour Khan,
Voici la totalité de mon fichier php original :
Je le remets ci-essous ....
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<body bgcolor="#418FCD">
<p align="left"><strong><u>Tableau pilotes</u></strong></p>
<p align="justify"> </p>
<p align="justify">Cliquez sur le callsign d'un pilote pour accéder à son carnet de vol. </p>
<p align="justify"> </p>
<div align="center">
<!-- begin FSACARS Reports --><?php
/* Constants */
@define ("MYSQL_CONNECT_INCLUDE", "fsacars/connect_db.php"); // MySQL database connection
/* Database connection */
include(MYSQL_CONNECT_INCLUDE);
/* Select all pilots */
$query = "SELECT * FROM pilots ORDER BY pilot_id ASC";
$result = mysql_query($query);
/* Determine the number of pilots */
$number = mysql_numrows($result);
if ($number > 0) {
/* Print roster header
Change this HTML to fit your webpage layout */
print "<table>";
print "<tr>";
print "<td bgcolor=#87B5E2 width=70 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>PILOTE</b></font></td>";
print "<td bgcolor=#87B5E2 width=90 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>NOM</b></font></td>";
print "<td bgcolor=#87B5E2 width=110 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>TDV</b></font></td>";
print "<td bgcolor=#87B5E2 width=70 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>POIDS</b></font></td>";
print "<td bgcolor=#87B5E2 width=70 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>MN</b></font></td>";
print "<td bgcolor=#87B5E2 width=80 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>FUEL</b></font></td>";
print "<td bgcolor=#87B5E2 width=110 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>CA</b></font></td>";
print "</tr>";
/* Get pilots info */
for ($i=0; $i<$number; $i++) {
$num = mysql_result($result,$i,"pilot_num");
$name = mysql_result($result,$i, "name");
$city = mysql_result($result,$i, "city");
$country = mysql_result($result,$i, "country");
$status_fr = mysql_result($result,$i, "status_fr");
$ca= mysql_result($result,$i, "ca");
$id = mysql_result($result,$i, "pilot_id");
/* Calculate flight hours */
$query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_hours = mysql_query($query_hours);
if (mysql_numrows($result_hours) > 0) {
$time = mysql_result($result_hours,0,"duration_sum");
}
/* Calculate distance */
$query_dist = "SELECT (sum(t2.distance)) AS distance_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_dist = mysql_query($query_dist);
if (mysql_numrows($result_dist) > 0) {
$dist = mysql_result($result_dist,"distance_sum");
}
/* Calculate poids */
$query_poids = "SELECT (sum(t2.registration)) AS registration_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_poids = mysql_query($query_poids);
if (mysql_numrows($result_poids) > 0) {
$poids = mysql_result($result_poids,"registration_sum");
}
/* Calculate fuel */
$query_fuel = "SELECT (sum(t2.fuel)) AS fuel_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_fuel= mysql_query($query_fuel);
if (mysql_numrows($result_fuel) > 0) {
$fuel = mysql_result($result_fuel,"fuel_sum");
/* Calculate CA */
}
/* Display roster entries */
print "<tr>";
print "<td width=70 height=12 align=left><font face=Arial size=2 color=#FFFFFF> <a href=\"index.php?page=carnet$num\"> $num </a> </font></td>";
print "<td width=90 height=12 align=left><font face=Arial size=2 color=#FFFFFF>$name</font></td>";
print "<td width=110 height=12 align=center><font face=Arial size=2 color=#FFFFFF>$time</font></td>";
print "<td width=70 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$poids</font></td>";
print "<td width=70 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$dist</font></td>";
print "<td width=80 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$fuel</font></td>";
print "<td width=110 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$ca</font></td>" ;
print "</tr>";
}
print "</table>";
}
$query = "SELECT SEC_TO_TIME( SUM( TIME_TO_SEC(reports.duration))) AS SUM_OF_duration FROM reports";
$result = mysql_query($query) or die('0');
$data = mysql_fetch_row($result);
$sum = $data[0];
print "<td bgcolor=#FFFFFF width=73 height=12 align=left><font face=Arial color=#FFFFFF size=3><b>TEMPS DE VOL TOTAL DE LA VA: </b></font></td>";
print "</tr>";
print "<td bgcolor=#FFFFFF width=73 height=12 align=right><font face=Arial size=4 color=#FFFFFF>$sum</font></td>";
print "</tr>";
/* Print table footer */
print "<table>";
print "<tr><td><font face=Arial size=2 color=#0000ff></font></td></tr>";
print "</table>";
/* Close the database connection */
mysql_close();
?><!-- end FSACARS Reports --></div>
<br>
</body>
Je comprends tout a fait ce que tu essaye de me faire faire ( ou plutot que tu fait ) harmoniser un ensemble de requette, ce qui me chagrine moi c'est que j'ouble toujours un truc du type ";","} ou { " c'est a chaque fois la même chose, bon je reste débutant dans le PHP ( mes base MySQL sont pas énormes , ca va j'y arrives ) mais c'est exclusivement en auto didact et ca c'est pas facil, ce qui est logique pour les développeur n'est pas forcémment logique pour un mec comme moi, je procède plutôt a petit pas, un cooup je fait ce calcul avec requette, ( il marche, c'est bon, je passe à un autre, et ainsi de suite. Au bout d'un momment, ben le code ça devient un peu le foutoir.
En tout cas,je te remercie du profond du coeur, l'ami de m'aider.
NB : J'utilise PsPAd Edotor v 4.5.3 (2298) pour mes pages PHP
Cordialement
Bonsoir Khan
Le fichier PHp qui tourne actuellement c'est celui que j'ai mis hier
[color=#0000FF] [i]de sbi016 le 14 Oct 2009, 07:31
Bonjour Khan,
Voici la totalité de mon fichier php original :[/i][/color]
Je le remets ci-essous ....
[php]<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<body bgcolor="#418FCD">
<p align="left"><strong><u>Tableau pilotes</u></strong></p>
<p align="justify"> </p>
<p align="justify">Cliquez sur le callsign d'un pilote pour accéder à son carnet de vol. </p>
<p align="justify"> </p>
<div align="center">
<!-- begin FSACARS Reports --><?php
/* Constants */
@define ("MYSQL_CONNECT_INCLUDE", "fsacars/connect_db.php"); // MySQL database connection
/* Database connection */
include(MYSQL_CONNECT_INCLUDE);
/* Select all pilots */
$query = "SELECT * FROM pilots ORDER BY pilot_id ASC";
$result = mysql_query($query);
/* Determine the number of pilots */
$number = mysql_numrows($result);
if ($number > 0) {
/* Print roster header
Change this HTML to fit your webpage layout */
print "<table>";
print "<tr>";
print "<td bgcolor=#87B5E2 width=70 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>PILOTE</b></font></td>";
print "<td bgcolor=#87B5E2 width=90 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>NOM</b></font></td>";
print "<td bgcolor=#87B5E2 width=110 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>TDV</b></font></td>";
print "<td bgcolor=#87B5E2 width=70 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>POIDS</b></font></td>";
print "<td bgcolor=#87B5E2 width=70 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>MN</b></font></td>";
print "<td bgcolor=#87B5E2 width=80 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>FUEL</b></font></td>";
print "<td bgcolor=#87B5E2 width=110 height=12 align=center><font face=Arial color=#FFFFFF size=2><b>CA</b></font></td>";
print "</tr>";
/* Get pilots info */
for ($i=0; $i<$number; $i++) {
$num = mysql_result($result,$i,"pilot_num");
$name = mysql_result($result,$i, "name");
$city = mysql_result($result,$i, "city");
$country = mysql_result($result,$i, "country");
$status_fr = mysql_result($result,$i, "status_fr");
$ca= mysql_result($result,$i, "ca");
$id = mysql_result($result,$i, "pilot_id");
/* Calculate flight hours */
$query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_hours = mysql_query($query_hours);
if (mysql_numrows($result_hours) > 0) {
$time = mysql_result($result_hours,0,"duration_sum");
}
/* Calculate distance */
$query_dist = "SELECT (sum(t2.distance)) AS distance_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_dist = mysql_query($query_dist);
if (mysql_numrows($result_dist) > 0) {
$dist = mysql_result($result_dist,"distance_sum");
}
/* Calculate poids */
$query_poids = "SELECT (sum(t2.registration)) AS registration_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_poids = mysql_query($query_poids);
if (mysql_numrows($result_poids) > 0) {
$poids = mysql_result($result_poids,"registration_sum");
}
/* Calculate fuel */
$query_fuel = "SELECT (sum(t2.fuel)) AS fuel_sum FROM pilots t1, reports t2 WHERE t1.pilot_id=$id AND t1.pilot_id=t2.pilot_id";
$result_fuel= mysql_query($query_fuel);
if (mysql_numrows($result_fuel) > 0) {
$fuel = mysql_result($result_fuel,"fuel_sum");
/* Calculate CA */
}
/* Display roster entries */
print "<tr>";
print "<td width=70 height=12 align=left><font face=Arial size=2 color=#FFFFFF> <a href=\"index.php?page=carnet$num\"> $num </a> </font></td>";
print "<td width=90 height=12 align=left><font face=Arial size=2 color=#FFFFFF>$name</font></td>";
print "<td width=110 height=12 align=center><font face=Arial size=2 color=#FFFFFF>$time</font></td>";
print "<td width=70 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$poids</font></td>";
print "<td width=70 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$dist</font></td>";
print "<td width=80 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$fuel</font></td>";
print "<td width=110 height=12 align=right><font face=Arial size=2 color=#FFFFFF>$ca</font></td>" ;
print "</tr>";
}
print "</table>";
}
$query = "SELECT SEC_TO_TIME( SUM( TIME_TO_SEC(reports.duration))) AS SUM_OF_duration FROM reports";
$result = mysql_query($query) or die('0');
$data = mysql_fetch_row($result);
$sum = $data[0];
print "<td bgcolor=#FFFFFF width=73 height=12 align=left><font face=Arial color=#FFFFFF size=3><b>TEMPS DE VOL TOTAL DE LA VA: </b></font></td>";
print "</tr>";
print "<td bgcolor=#FFFFFF width=73 height=12 align=right><font face=Arial size=4 color=#FFFFFF>$sum</font></td>";
print "</tr>";
/* Print table footer */
print "<table>";
print "<tr><td><font face=Arial size=2 color=#0000ff></font></td></tr>";
print "</table>";
/* Close the database connection */
mysql_close();
?><!-- end FSACARS Reports --></div>
<br>
</body>
[/php]
Je comprends tout a fait ce que tu essaye de me faire faire ( ou plutot que tu fait ) harmoniser un ensemble de requette, ce qui me chagrine moi c'est que j'ouble toujours un truc du type ";","} ou { " c'est a chaque fois la même chose, bon je reste débutant dans le PHP ( mes base MySQL sont pas énormes , ca va j'y arrives ) mais c'est exclusivement en auto didact et ca c'est pas facil, ce qui est logique pour les développeur n'est pas forcémment logique pour un mec comme moi, je procède plutôt a petit pas, un cooup je fait ce calcul avec requette, ( il marche, c'est bon, je passe à un autre, et ainsi de suite. Au bout d'un momment, ben le code ça devient un peu le foutoir.
En tout cas,je te remercie du profond du coeur, l'ami de m'aider.
NB : J'utilise PsPAd Edotor v 4.5.3 (2298) pour mes pages PHP
Cordialement