vavoir,
il y a 12 ans
Ok j'ai rien dit je sort...
<?php
require('php/connect.php');
if(isset($_POST) && !empty($_POST)){
if(isset($_POST'suppr']) && isset($_POST'id'])){
echo "tu veux supprimer".$_POST'id'];
}
elseif(isset($_POST'inbox']) && isset($_POST'id'])){
try {
foreach($_POST'id'] as $id){
$count = $bdd->exec('UPDATE contacte SET type="1" WHERE id="'.$id.'" ');
}
$count = $bdd->exec('UPDATE contacte SET type="1" WHERE id="" ');
echo '<p>Message placer dans boite de reception !</p>';
}
catch(PDOException $e){
echo '<p>Erreur lors de l\'insertion : '.$e->getMessage().'</p>';
}
}
}
echo '<hr><h4 style="margin-top: 50px;">Message mis à la corbeille</h4><hr><form action="?action=letter&letter=trash" method="POST"><table class="table table-striped" ><tbody>';
$inboxbdd = $bdd->prepare('SELECT id, name, text FROM contacte WHERE type="2" '); $inboxbdd->execute();
while ($inbox = $inboxbdd->fetch()){
$chaine = $inbox'text'];
$lg_max = 80; //nombre de caractères autorisés
if (strlen($chaine) > $lg_max){
$chaine = substr($chaine, 0, $lg_max);
$last_space = strrpos($chaine, " ");
$chaine = substr($chaine, 0, $last_space)."...";
}
?>
<tr>
<td><input type="checkbox" name="id]" value="<?php echo $inbox'id']; ?>" ></td>
<td><?php echo $inbox'name']; ?></td>
<td><a href="?action=letter&letter=inbox&inbox=true&id=<?php echo $inbox'id']; ?>" ><?php echo $chaine; ?></a></td>
</tr>
<?php
}
echo '</tbody>
<tr><td colspan="3" >
<input type="submit" value="Retirer de la corbeil" name="inbox" >
<input type="submit" value="Supprimer définitivement" name="suppr" >
</td></tr>
</table></form>';
$inboxbdd->closeCursor();
Les joies de la programmation nocturne !