Je cherche une façon d'optimiser un script php.
Je débute pour le coup et je n'ai pas vraiment d'idée sur la façon de faire.
Voici mon bout de code tableau.php :
Code : Tout sélectionner
<HTML>
<head>
<style>
BODY { font-family : Verdana,Arial; }
TD { font-family : Verdana,Arial; font-size : 8pt; }
A { text-decoration : none; background-color : #A8D3ED; }
</style>
</head>
<body bgcolor=#a8d3ed link=#339933>
<br>
<?php
if(empty($type)) {
$type = "$nom";
}
echo "
<table border=\"1\">
<CAPTION>Titre de mon tableau</CAPTION>
<tr>
<th colspan=\"1\" rowspan=\"3\">date</th>
<th colspan=\"1\" rowspan=\"3\"><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=\">total</a></th>
<th colspan=\"7\" rowspan=\"1\">Type : $type</td></tr>
<tr><th colspan=\"3\" rowspan=\"1\">Active</td>
<th colspan=\"4\" rowspan=\"1\">Inactive</td></tr>
<tr><th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=^active\">total active</a></th>
<th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=^active&etat=production\">en production</a></th>
<th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=^active&etat=test\">en test</a></th>
<th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=inactive\">total inactive</a></th>
<th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=inactive&etat=param\">en parametrage</a></th>
<th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=inactive&etat=production\">en production</a></th>
<th><a href=\"http://monsite/cgi-bin/monurl&type=$type&active=inactive&etat=etat2\">en demande de valid</th></tr>
</tr>";
// on recupere la variable
$lignes = file("$nom");
// traitement de chaque ligne
for ($i=0; $i<count($lignes); $i++) {
$couleur_ligne = ($i % 2)
? '#B8C8FE'
: '#EEEEEE';
echo "<tr>";
$statistiques=explode(" ",$lignes[$i]);
for ($a=0; $a<count($statistiques); $a++){
echo "<td bgcolor=\"".$couleur_ligne."\">".$statistiques[$a];
}
echo "</tr>";
}
echo "</table>
<br>
<A Href=\"export.php\"><u>Exporter le tableau</u></A>";
?>
</BODY></HTML>Merci !!