par
newbit » 23 avr. 2011, 15:30
Bonjour à tous,
je débute avec php, j'ai trouvé ce script
$mois=date("n");
$an=date("Y");
$ligne_jours = array();
$ligne_date = array();
$ligne_donnee = array();
$aJours = array('0' => 'Dim', '1' => 'Lun', '2' => 'Mar', '3' => 'Mer', '4' => 'Jeu', '5' => 'Ven', '6' => 'Sam');
$aPersonne = array('1');
$njours = date('t', mktime(0,0,0,$mois,1,$an));
//construction
for ($jour = 1; $jour <= $njours; $jour++) {
$timestamp = mktime(0,0,0,$mois,$jour,$an);
$ligne_jours[$timestamp] = '<td>' . $aJours[date('w', $timestamp)] . '</td>';
$ligne_date[$timestamp] = '<td>' . $jour . '</td>';
foreach ($aPersonne as $personne) {
$ligne_donnee[$personne][$timestamp] = '<td><input type="checkbox" name="' . $personne . '[' . $timestamp . ']" /></td>';
}
}
$mois_fr = Array("", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
$mois_fr[$mois];
//affichage tableau
echo '<table style="background-color: white;">
<tr style="background-color: rgb(157, 205, 79);"align="center"> <td colspan="36" rowspan="1">'.$mois_fr[$mois].' '.$an.'</td>
</tr>
<tr>
<td></td>' . implode('',$ligne_jours) . '
</tr>
<tr>
<td></td>' . implode('',$ligne_date) . '
</tr>';
foreach ($ligne_donnee as $nom=>$ligne_personne) {
echo '<tr>
<td>' . $nom . '</td>' . implode('',$ligne_personne) . '
</tr>';
}
echo '</table>';
Pourriez-vous m'expliquer comment je peux insérer des données d'une table pour que certaines cases soient cochées
$result = mysql_query("SELECT * FROM dispo where id_personne ='$personne'");
while ($a = mysql_fetch_array($result)) {
if ($a['dispo']==$timestamp) {
$activite ='checked="checked"';
}
else {
$activite ='';
}
}
Bonjour à tous,
je débute avec php, j'ai trouvé ce script
[php]$mois=date("n");
$an=date("Y");
$ligne_jours = array();
$ligne_date = array();
$ligne_donnee = array();
$aJours = array('0' => 'Dim', '1' => 'Lun', '2' => 'Mar', '3' => 'Mer', '4' => 'Jeu', '5' => 'Ven', '6' => 'Sam');
$aPersonne = array('1');
$njours = date('t', mktime(0,0,0,$mois,1,$an));
//construction
for ($jour = 1; $jour <= $njours; $jour++) {
$timestamp = mktime(0,0,0,$mois,$jour,$an);
$ligne_jours[$timestamp] = '<td>' . $aJours[date('w', $timestamp)] . '</td>';
$ligne_date[$timestamp] = '<td>' . $jour . '</td>';
foreach ($aPersonne as $personne) {
$ligne_donnee[$personne][$timestamp] = '<td><input type="checkbox" name="' . $personne . '[' . $timestamp . ']" /></td>';
}
}
$mois_fr = Array("", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
$mois_fr[$mois];
//affichage tableau
echo '<table style="background-color: white;">
<tr style="background-color: rgb(157, 205, 79);"align="center"> <td colspan="36" rowspan="1">'.$mois_fr[$mois].' '.$an.'</td>
</tr>
<tr>
<td></td>' . implode('',$ligne_jours) . '
</tr>
<tr>
<td></td>' . implode('',$ligne_date) . '
</tr>';
foreach ($ligne_donnee as $nom=>$ligne_personne) {
echo '<tr>
<td>' . $nom . '</td>' . implode('',$ligne_personne) . '
</tr>';
}
echo '</table>';[/php]
Pourriez-vous m'expliquer comment je peux insérer des données d'une table pour que certaines cases soient cochées :oops:
[php]$result = mysql_query("SELECT * FROM dispo where id_personne ='$personne'");
while ($a = mysql_fetch_array($result)) {
if ($a['dispo']==$timestamp) {
$activite ='checked="checked"';
}
else {
$activite ='';
}
}[/php]