1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<form name="insertion" action="" method="POST">
<table border="0" align="center" cellspacing="2" cellpadding="2" >
<tr align="center">
<td>Nom : </td>
<td><input type="text" name="nom"></td>
</tr>
<tr align="center">
<td>Prenom : </td>
<td><input type="text" name="prenom"></td>
</tr>
<tr align="center">
<td>Type d'affichage : </td>
<td><select name="type">
<option value="jour" >jour</option>
<option value="mois" >mois</option>
<option value="annee" >annee</option>
<option value="complet" >complet</option>
</select></td></tr>
<tr align="center">
<td colspan="2"><input type="submit" value="ok"></td>
</tr>
</table>
</form>
</div>
<?php
//connection au serveur:
$cnx = mysql_connect( "localhost", "root", "" ) ;
//sélection de la base de données:
$db = mysql_select_db( "greg" ) ;
$nom="";
if(!empty($_POST["nom"]))
$nom=$_POST["nom"];
$prenom="";
if(!empty($_POST["prenom"]))
$prenom=$_POST["prenom"];
$type="";
if(!empty($_POST["type"]))
$type=$_POST["type"];
if($type == "annee"){
echo "<form name=\"bb\" method=\"POST\">";
echo "<table border=\"0\" align=\"center\"\ cellspacing=\"2\" cellpadding=\"2\" >";
echo "<tr><td>Choisir l'annee : </td><td><select name=\"annee\" >";
for ($i=2010; $i<2016; $i++){
echo "<option value= $i >",$i,"</option>";}
echo "</select></td></tr>";
echo "<tr align=\"center\"><td colspan=\"2\"><input type=\"submit\" value=\"ok\"></td></tr>";
echo "</table></form>";
if(!empty($_POST["annee"]))
$annee=$_POST["annee"];
$sql="SELECT * FROM agenda WHERE nom='$nom' AND prenom='$prenom' AND annee='$annee' ORDER by mois";
$requete = mysql_query( $sql, $cnx ) ;
echo "<div class=\"kuku\">";
echo '<table border>';
echo'<tr><td>date</td><td>heure</td><td>evenement</td></tr>';
while( $result = mysql_fetch_object( $requete ) )
{
echo "<tr><td>".$result->jour."-".$result->mois."-".$result->annee."</td><td>".$result->heure."h".$result->minute."</td><td>".$result->contenu."</td></tr>" ;
}
echo "</table>";
echo "</div>";
}
//affichage par mois
elseif ($type =="mois"){
echo "<form name=\"bb\" method=\"POST\">";
echo "<table border=\"0\" align=\"center\"\ cellspacing=\"2\" cellpadding=\"2\" >";
echo "<tr><td>Choisir le mois : </td><td><select name=\"mois\" >";
for ($i=1; $i<13; $i++){
echo "<option value= $i >",$i,"</option>";}
echo"</select></td></tr>";
echo "<tr align=\"center\"><td colspan=\"2\"><input type=\"submit\" value=\"ok\"></td></tr>";
$mois="";
if(!empty($_POST["mois"]))
$mois=$_POST["mois"];
$sql="SELECT * FROM agenda WHERE nom='$nom' AND prenom='$prenom' AND mois='$mois' ORDER by jour";
$requete = mysql_query( $sql, $cnx ) ;
echo "<div class=\"kuku\">";
echo '<table border>';
echo'<tr><td>date</td><td>heure</td><td>evenement</td></tr>';
while( $result = mysql_fetch_object( $requete ) )
{
echo "<tr><td>".$result->jour."-".$result->mois."-".$result->annee."</td><td>".$result->heure."h".$result->minute."</td><td>".$result->contenu."</td></tr>" ;
}
echo "</table>";
echo "</div>";
}
//affichage par jour
elseif ($type =="jour"){
echo "<form name=\"bb\" method=\"POST\">";
echo "<table border=\"0\" align=\"center\"\ cellspacing=\"2\" cellpadding=\"2\" >";
echo "<tr><td>Choisir le jour : </td><td><select name=\"jour\" >";
for ($i=1; $i<32; $i++){
echo "<option value= $i >",$i,"</option>";}
echo"</select></td></tr>";
echo "<tr align=\"center\"><td colspan=\"2\"><input type=\"submit\" value=\"ok\"></td></tr>";
$jour="";
if(!empty($_POST["jour"]))
$jour=$_POST["jour"];
$sql="SELECT * FROM agenda WHERE nom='$nom' AND prenom='$prenom' AND jour='$jour' ORDER by annee";
$requete = mysql_query( $sql, $cnx ) ;
echo "<div class=\"kuku\">";
echo '<table border>';
echo'<tr><td>date</td><td>heure</td><td>evenement</td></tr>';
while( $result = mysql_fetch_object( $requete ) )
{
echo "<tr><td>".$result->jour."-".$result->mois."-".$result->annee."</td><td>".$result->heure."h".$result->minute."</td><td>".$result->contenu."</td></tr>" ;
}
echo "</table>";
echo "</div>";
}
elseif ($type =="complet"){
$sql="SELECT * FROM agenda WHERE nom='$nom' AND prenom='$prenom' ORDER by annee";
$requete = mysql_query( $sql, $cnx ) ;
echo "<div class=\"kuku\">";
echo '<table border>';
echo'<tr><td>date</td><td>heure</td><td>evenement</td></tr>';
while( $result = mysql_fetch_object( $requete ) )
{
echo "<tr><td>".$result->jour."-".$result->mois."-".$result->annee."</td><td>".$result->heure."h".$result->minute."</td><td>".$result->contenu."</td></tr>" ;
}
echo "</table>";
echo "</div>";
}
$cnx= mysql_close();
?>
</body>
</html> |
Partager