thank you for your answer, i can't write chinses right now, you solution can't work....the date and the year exist at the same time... and because it's also connect to the BD, if i use you solution, the result is wrong, i don't know why............ it's anybody can help me?? thank you thank you aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<?phpecho "<div id=\"retour\"><a href=\"../Php/appli.php?EX=statistiques\"></a></div>";echo" <script language=\"JavaScript\"> function selectType(id){ if(id=\"tri_annee\"){ $(\"#byyear\").style.display=\"\"; $(\"#bydate\").style.display=\"none\"; }else if(id=\"tri_date\") { $(\"#byyear\").style.display=\"none\"; $(\"#bydate\").style.display=\"\"; } } </script>";//On recupere la liste des utilisateur $query = "SELECT ID_U FROM UTILISATEUR WHERE ID_U != 'root'"; $MySql = new CTables(); $MySql->Set_query($query); $MySql->Select_all(); $Result_Dem = $MySql->Get_the_values();//On recupere la liste des Projet $Result_Proj = GetListProjet();//titre de page echo"<h2>Statistiques de Demandes d'Achat</h2>"; /*********************************formulaire de tri et recherche...********************************/echo"<div id=\"statis_da_tri\"><form id=\"formstatis_da_tri\" onsubmit=\"return VerifListeFt();\" action=\"../Php/appli.php?EX=statis_da\" method=\"post\"><p>";echo" Projet : <select name=\"Liste_Projet\">"; //tri par projet echo "<option value=\"TOUS\">Tous</option>"; for ($i=0; $i < count($Result_Proj); ++$i) { $SEL = ($_POST['Liste_Projet'] == $Result_Proj[$i]['CODE_PROJET']) ? " selected=\"selected\" " : ""; echo "<option value=\"{$Result_Proj[$i]['CODE_PROJET']}\"$SEL>{$Result_Proj[$i]['NOM_PROJ']}</option>"; } echo"</select></p>"; echo"<p style='color:red;font-size:14px; font-style:arial'><input type=\"radio\" name=\"radio\" id=\"tri_date\" value=\"\" onclick=\"selectType(this)\"/> <strong>Case à cocher si vous voulez chercher Nombre de demandes de travaux par année!!</strong></p>";echo"<p id=\"bydate\"><label>Date Minimum : </label> <input type=\"text\" name=\"DATE_MIN\" value=\"{$_POST['DATE_MIN']}\" maxlength=\"10\" /> <input type=\"image\" onclick=\"return PopUpCalend('formstatis_da_tri','DATE_MIN','Lien1');\" id=\"Lien1\" src=\"../Img/b_calendar.png\"/> <label>Date Maximum : </label><input type=\"text\" name=\"DATE_MAX\" value=\"{$_POST['DATE_MAX']}\" maxlength=\"10\" /> <input type=\"image\" onclick=\"return PopUpCalend('formstatis_da_tri','DATE_MAX','Lien2');\" id=\"Lien2\" src=\"../Img/b_calendar.png\"/></p>";//Nombre de demandes de travaux par année. echo"<p style='color:red;font-size:14px; font-style:arial'><input type=\"radio\" name=\"radio\" id=\"tri_annee\" value=\"\" onclick=\"selectType(this)\"/> <strong>Case à cocher si vous voulez chercher Nombre de demandes de travaux par année!!</strong></p>";//Tri par année $query_date = "select distinct year(DATE_C) from DEMANDE_ACHAT ORDER BY DATE_C ASC "; $MySql_date = new ctables(); $MySql_date->Set_query($query_date); $MySql_date->Select_all(); $list_date = $MySql_date->Get_the_values();echo "<p id=\"byyear\">Année :"; echo "<select name=\"Liste_Annee\">"; for ($i = count($list_date); $i >= 0 ; --$i) { $SEL = ($_POST['Liste_Annee'] == $list_date[$i][0]) ? " selected=\"selected\" " : ""; echo "<option value=\"{$list_date[$i][0]}\"$SEL>{$list_date[$i][0]}</option>"; } echo "<option value=\"Toute\">Toutes</option>"; echo"</select></p>";echo"<p><input type=\"submit\" name=\"TRI_LISTE\" value=\"Valider\" /></p> </form></div>"; /**************************************la liste des fiche commande***************************************/echo"<div id=\"Liste_da\">"; $query = "SELECT NOM_PROJ,DOC_GEN.CODE_PROJET, SUM(NUM_DOC), SUM(TOTAL_C+FDP) FROM DOC_GEN, DEMANDE_ACHAT, PROJET WHERE DOC_GEN.ID_DOC_GEN = DEMANDE_ACHAT.ID_DOC_GEN AND PROJET.CODE_PROJET=DOC_GEN.CODE_PROJET";
if (!empty($_POST['Liste_Projet']) && $_POST['Liste_Projet'] != TOUS) $query = $query . " AND DOC_GEN.CODE_PROJET = '$_POST[Liste_Projet]'";if($_POST['tri_date'] !='off' && $_POST['tri_annee'] !='on') { if (!empty($_POST['DATE_MIN'])) $query = $query . " AND DATE_C >= '" . datefr2MySql ($_POST[DATE_MIN]) . "'"; if (!empty($_POST['DATE_MAX'])) $query = $query . " AND DATE_C <= '" . datefr2MySql ($_POST[DATE_MAX]) . "'"; }if($_POST['tri_annee'] !='off' && $_POST['tri_date'] !='on') { if(!empty($_POST['Liste_Annee'])) { if($_POST['Liste_Annee'] == "Toute") $query = $query ; else if ($_POST['Liste_Annee'] == date('Y')) $query = $query . " AND YEAR(DATE_C) = '" . date('Y') . "'"; else $query = $query . " AND YEAR(DATE_C) = '" . $_POST['Liste_Annee'] . "'"; } } $query = $query . " GROUP BY DOC_GEN.CODE_PROJET"; $query = $query . " ORDER BY NOM_PROJ ASC"; $MySql->Set_query($query); $MySql->Select_all(); $the_Liste=$MySql->Get_the_values(); $nb_ft = count($the_Liste); if($nb_ft == 0) echo"<p>il n'y a aucune demande d'achat existante</p>"; //affiche si pas de fiche travaux ... else { echo"<div id=\"centrefournis\"><table>"; echo"<tr><td bgcolor=skyblue>Nom du projet</td><td bgcolor=skyblue>Nombre de Commandes</td><td bgcolor=skyblue>Montants(HT)</td></tr>";
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'visible';
}
else { // IE 4
document.all.hideshow.style.visibility = 'visible';
}
}
}或者document.getElementById('viewTb').style.display = 'block';
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'visible';
}
else { // IE 4
document.all.hideshow.style.visibility = 'visible';
}
}
}或者document.getElementById('viewTb').style.display = 'block';
function selectType(id){
if(id="r1"){
$("#byYear").style.display="";//年显示
$("#byTime").style.display="none";//时间段隐藏}else if(id="r2") {
$("#byYear").style.display="none";//年隐藏
$("#byTime").style.display="";//时间段显示}
}
<input type="radio" id="r1" name="radio" onclick="selectType(this)"/>按年查询
<input type="radio" id="r2" name="radio" onclick="selectType(this)"/>按时间段查询
<input type="text" id="byYear" name="year" />
<input type="text" id="byTime" name="time" />
<script language=\"JavaScript\">
function selectType(id){
if(id=\"tri_annee\"){
$(\"#byyear\").style.display=\"\";
$(\"#bydate\").style.display=\"none\"; }else if(id=\"tri_date\") {
$(\"#byyear\").style.display=\"none\";
$(\"#bydate\").style.display=\"\"; }
}
</script>";//On recupere la liste des utilisateur
$query = "SELECT ID_U FROM UTILISATEUR WHERE ID_U != 'root'";
$MySql = new CTables();
$MySql->Set_query($query);
$MySql->Select_all();
$Result_Dem = $MySql->Get_the_values();//On recupere la liste des Projet
$Result_Proj = GetListProjet();//titre de page
echo"<h2>Statistiques de Demandes d'Achat</h2>"; /*********************************formulaire de tri et recherche...********************************/echo"<div id=\"statis_da_tri\"><form id=\"formstatis_da_tri\" onsubmit=\"return VerifListeFt();\" action=\"../Php/appli.php?EX=statis_da\" method=\"post\"><p>";echo" Projet : <select name=\"Liste_Projet\">"; //tri par projet
echo "<option value=\"TOUS\">Tous</option>";
for ($i=0; $i < count($Result_Proj); ++$i)
{
$SEL = ($_POST['Liste_Projet'] == $Result_Proj[$i]['CODE_PROJET']) ? " selected=\"selected\" " : "";
echo "<option value=\"{$Result_Proj[$i]['CODE_PROJET']}\"$SEL>{$Result_Proj[$i]['NOM_PROJ']}</option>";
}
echo"</select></p>"; echo"<p style='color:red;font-size:14px; font-style:arial'><input type=\"radio\" name=\"radio\" id=\"tri_date\" value=\"\" onclick=\"selectType(this)\"/> <strong>Case à cocher si vous voulez chercher Nombre de demandes de travaux par année!!</strong></p>";echo"<p id=\"bydate\"><label>Date Minimum : </label>
<input type=\"text\" name=\"DATE_MIN\" value=\"{$_POST['DATE_MIN']}\" maxlength=\"10\" />
<input type=\"image\" onclick=\"return PopUpCalend('formstatis_da_tri','DATE_MIN','Lien1');\" id=\"Lien1\" src=\"../Img/b_calendar.png\"/>
<label>Date Maximum : </label><input type=\"text\" name=\"DATE_MAX\" value=\"{$_POST['DATE_MAX']}\" maxlength=\"10\" />
<input type=\"image\" onclick=\"return PopUpCalend('formstatis_da_tri','DATE_MAX','Lien2');\" id=\"Lien2\" src=\"../Img/b_calendar.png\"/></p>";//Nombre de demandes de travaux par année.
echo"<p style='color:red;font-size:14px; font-style:arial'><input type=\"radio\" name=\"radio\" id=\"tri_annee\" value=\"\" onclick=\"selectType(this)\"/> <strong>Case à cocher si vous voulez chercher Nombre de demandes de travaux par année!!</strong></p>";//Tri par année
$query_date = "select distinct year(DATE_C) from DEMANDE_ACHAT ORDER BY DATE_C ASC ";
$MySql_date = new ctables();
$MySql_date->Set_query($query_date);
$MySql_date->Select_all();
$list_date = $MySql_date->Get_the_values();echo "<p id=\"byyear\">Année :";
echo "<select name=\"Liste_Annee\">";
for ($i = count($list_date); $i >= 0 ; --$i)
{
$SEL = ($_POST['Liste_Annee'] == $list_date[$i][0]) ? " selected=\"selected\" " : "";
echo "<option value=\"{$list_date[$i][0]}\"$SEL>{$list_date[$i][0]}</option>";
}
echo "<option value=\"Toute\">Toutes</option>";
echo"</select></p>";echo"<p><input type=\"submit\" name=\"TRI_LISTE\" value=\"Valider\" /></p>
</form></div>";
/**************************************la liste des fiche commande***************************************/echo"<div id=\"Liste_da\">";
$query = "SELECT NOM_PROJ,DOC_GEN.CODE_PROJET, SUM(NUM_DOC), SUM(TOTAL_C+FDP)
FROM DOC_GEN, DEMANDE_ACHAT, PROJET
WHERE DOC_GEN.ID_DOC_GEN = DEMANDE_ACHAT.ID_DOC_GEN
AND PROJET.CODE_PROJET=DOC_GEN.CODE_PROJET";
if (!empty($_POST['Liste_Projet']) && $_POST['Liste_Projet'] != TOUS)
$query = $query . " AND DOC_GEN.CODE_PROJET = '$_POST[Liste_Projet]'";if($_POST['tri_date'] !='off' && $_POST['tri_annee'] !='on')
{
if (!empty($_POST['DATE_MIN']))
$query = $query . " AND DATE_C >= '" . datefr2MySql ($_POST[DATE_MIN]) . "'";
if (!empty($_POST['DATE_MAX']))
$query = $query . " AND DATE_C <= '" . datefr2MySql ($_POST[DATE_MAX]) . "'";
}if($_POST['tri_annee'] !='off' && $_POST['tri_date'] !='on')
{
if(!empty($_POST['Liste_Annee']))
{
if($_POST['Liste_Annee'] == "Toute")
$query = $query ;
else if ($_POST['Liste_Annee'] == date('Y'))
$query = $query . " AND YEAR(DATE_C) = '" . date('Y') . "'";
else
$query = $query . " AND YEAR(DATE_C) = '" . $_POST['Liste_Annee'] . "'";
}
} $query = $query . " GROUP BY DOC_GEN.CODE_PROJET";
$query = $query . " ORDER BY NOM_PROJ ASC"; $MySql->Set_query($query);
$MySql->Select_all();
$the_Liste=$MySql->Get_the_values();
$nb_ft = count($the_Liste); if($nb_ft == 0)
echo"<p>il n'y a aucune demande d'achat existante</p>"; //affiche si pas de fiche travaux ...
else
{
echo"<div id=\"centrefournis\"><table>";
echo"<tr><td bgcolor=skyblue>Nom du projet</td><td bgcolor=skyblue>Nombre de Commandes</td><td bgcolor=skyblue>Montants(HT)</td></tr>";
for($i=0,$t=0 ; $i < $nb_ft ; ++$i )
{
echo "<tr> <td class=\"bgc2\">{$the_Liste[$i]['NOM_PROJ']}</td>
<td class=\"bgc2\">{$the_Liste[$i]['SUM(NUM_DOC)']}</td>
<td class=\"bgc2\">{$the_Liste[$i]['SUM(TOTAL_C+FDP)']}</td>";
echo "</tr>";
$t=$t+$the_Liste[$i]['SUM(NUM_DOC)'];
$h=$h+$the_Liste[$i]['SUM(TOTAL_C+FDP)'];
} echo"<tr><td bgcolor=skyblue><strong>TOTAL</strong></td><td bgcolor=skyblue><strong>$t</strong></td><td bgcolor=skyblue><strong>$h</strong></td></tr>";
echo "</table></div></div><br/>";
}
?>
如果刷新了,那么必须想办法保存当前页面的显示隐藏状态!比如你可以串1010这样的字符串到下一个页面,然后下个页面解析字符串,如1表示时间隐藏,0表示什么显示等等。 这段解析要在网页刷新加载时执行。当前的显示隐藏状态你也可以存在本地cookie中。其实本质都是一样的,你要记录这些状态,然后在下个页面重现这些状态。
thanks all the same and have a nice day ^_^