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
| <form method="POST" action="Licences.php">
<script src="//cdn.jsdelivr.net/webshim/1.14.5/polyfiller.js"></script>
<?php
echo'<table class="tg" border="0" cellspacing="3" >';
$db = mysqli_connect($localhost,$login,$pwd,$dbName) or die('Erreur de connexion '.mysql_error());
$res = $db -> query ('SELECT COUNT(*) AS total FROM licences') OR die(mysql_error());
$row = mysqli_fetch_array($res);
?>
<style type="text/css">
#cellules
td {
padding: 5px;
.tg {box-shadow: 1px 1px 12px #555;}
}
</style>
<?php
echo"<tr>";
echo"<th height=50 align=center bgcolor=#beceff>ID</th>";
echo"<th align=center bgcolor=#beceff>TYPE</th>";
echo"<th align=center bgcolor=#beceff>ATO / Organisation</th>";
echo"<th align=center bgcolor=#beceff>Date of Issue</th>";
echo"<th align=center bgcolor=#beceff>Expire Date</th>";
echo"</tr>";
$offset = ((isset($_REQUEST['offset']) && $_REQUEST['offset'] > 0) ? $_REQUEST['offset'] : 0);
$sql_str = 'SELECT SQL_CALC_FOUND_ROWS * FROM licences ORDER BY ID LIMIT '.$offset.', '.$limit3.' ';
$result = $db -> query($sql_str); while ($data = mysqli_fetch_array($result)) {
echo"<tr id=cellules >";
echo"<td height=30 bgcolor=#D7E1FF><input name='id' value=".($data['ID'])."></td>";
echo"<td bgcolor=#D7E1FF>".$data['type']."</td>";
echo"<td bgcolor=#D7E1FF>".$data['ato']."</td>";
echo"<td width=150 align=center bgcolor=#D7E1FF><input name='datedebut' type='date' value=".($data['datedebut'])."></td>";
if ($data['datefin']==="0000-00-00")
{
echo"<td bgcolor=#D7E1FF>'Valid for Life'</td>";
}
else
{
echo"<td width=150 align=center bgcolor=#D7E1FF><input name='datefin' type='date' value=".($data['datefin'])."></td>";
}
echo"</tr>";
}
echo "</table>";
}
}
?>
<input class="css_button" type="submit" value="Mettre à jour les licenses..." name="envoyer">
<?php
// On commence par répérer les champs
if(isset($_POST['datedebut'])) $datedebut=$_POST['datedebut'];
else $datedebut="";
if(isset($_POST['datefin'])) $datefin=$_POST['datefin'];
else $datefin="";
if(isset($_POST['id'])) $id=$_POST['id'];
else $id="";
// On vérifie si les champs sont vides
if(empty($datedebut) OR empty($datefin))
{
echo "</br></br>";
}
// Aucun champ n'est vide, on peut enregistrer dans la table
else
{
$db = mysqli_connect($localhost,$login,$pwd,$dbName) or die('Erreur de connexion '.mysql_error());
$sql = "UPDATE licences SET datedebut='$datedebut',datefin='$datefin' WHERE id='$id'";
$res= $db -> query($sql) or die('Erreur SQL DE MERDE !'.$sql.'<br>'.mysql_error());
mysqli_close($db);
?>
<?php
}
?> |