Gestion checkbox avec php
Fermé
pantiri
Messages postés
10
Date d'inscription
mardi 6 juillet 2004
Statut
Membre
Dernière intervention
2 février 2007
-
1 févr. 2007 à 17:57
plop! Messages postés 54 Date d'inscription jeudi 1 février 2007 Statut Membre Dernière intervention 16 mai 2007 - 2 févr. 2007 à 20:48
plop! Messages postés 54 Date d'inscription jeudi 1 février 2007 Statut Membre Dernière intervention 16 mai 2007 - 2 févr. 2007 à 20:48
A voir également:
- Gestion checkbox avec php
- Easy php - Télécharger - Divers Web & Internet
- Logiciel gestion photo gratuit - Guide
- Logiciel gestion cave à vin gratuit excel - Télécharger - Cuisine & Gastronomie
- Gestion autorisation application android - Guide
- Logiciel gestion locative gratuit excel - Télécharger - Comptabilité & Facturation
3 réponses
plop!
Messages postés
54
Date d'inscription
jeudi 1 février 2007
Statut
Membre
Dernière intervention
16 mai 2007
27
2 févr. 2007 à 00:36
2 févr. 2007 à 00:36
Il faudrait le code source HTML du formulaire qui a généré ce résultat.
Et donne le code PHP qui précède ton for : comment récupères-tu $nbr_entrees ? etc ...
Et ce serait royal si tu pouvais donner la sortie d'un
Et donne le code PHP qui précède ton for : comment récupères-tu $nbr_entrees ? etc ...
Et ce serait royal si tu pouvais donner la sortie d'un
print_r($_GET)[ ou $_POST si c'est en post) ] également (mais si c'est trop compliqué, laisse tomber).
pantiri
Messages postés
10
Date d'inscription
mardi 6 juillet 2004
Statut
Membre
Dernière intervention
2 février 2007
2 févr. 2007 à 03:22
2 févr. 2007 à 03:22
Merci pour ton aide, voici le code enier
<?php
include("parametres.php");
$DB_link = mysql_connect($host,$user,"");
$requette = " select * from $table where actif = '1' order by date desc, heure desc ";
$resultat = mysql_db_query($database,$requette,$DB_link);
$nbr_entrees = mysql_num_rows($resultat);
$a = array();
function affichage_unique($var)
{
echo "<tr bgcolor=\"#CCCCCC\">";
//Date
$tmp = $var;
echo "<th width=\"10%\" align=left nowrap>".$tmp."</th>";
//email
echo "<th width=\"12%\" align=left nowrap>".$tmp."</th>";
//Type de Message
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th>";
//Message
echo "<th width=\"500\" align=left nowrap>".$tmp."</th>";
//Bouton Repondre
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th>";
//Bouton Supprimer
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th></tr>";
};
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Listing des entrée dans la base : </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body { font-family: Verdana; font-size: 12px; font-weight: normal; color: #000000;}
A:link { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
A:active { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
A:visited { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
.title { font-family: Verdana; font-size: 14px; font-weight: bold; color: #404040; text-decoration: none;}
.menu { font-family: Verdana; font-size: 12px; font-weight: normal; color: #000000; text-decoration: none;}
.texte { font-family: Verdana; font-size: 12px; font-weight: normal; color: #000000; text-decoration: none;}
.com { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
.minitxt { font-family: Verdana; font-size: 9px; font-weight: normal; color: #000000; text-decoration: none;}
.minitxtred{ font-family: Verdana; font-size: 9px; font-weight: normal; color: #FF0000; text-decoration: none;}
.special { font-family: Verdana; font-size: 8px; font-weight: normal; color: #595959; text-decoration: none;}
--></style>
</head>
<body>
<table class="texte" width="100%" border=0 cellspacing=1 cellpadding=2>
<form name="listing" action="<?php echo $PHP_SELF;?>" method="post" >
<tr bgcolor="#FF8F15">
<td class="title" align=center colspan=6> <a class="minitxt" href="listing.php">Le
Sirroco Listing</a><br>
<a class="com" href="index.php">Retour
à la page d'accueil</a> : <a class="com" href="contact.php">Contact</a>
</td>
</tr>
<tr bgcolor="#FFEAD5">
<th align=left width="1%" nowrap></th>
<th align=left width="9%" nowrap>Date</th>
<th align=left width="15%" nowrap>Adresse mail/N° Tel</th>
<th align=left width="10%" nowrap>Type de message</th>
<th align=left width="40%" nowrap>Messages <input type="submit" name = "supprimer" value="Supprimer"> <input type="submit" name ="repondre" value="répondre"> </th>
<th align=left width="8%" nowrap> Statut</th>
</tr>
<?php
if ($nbr_entrees != 0)
{
for ($i = 1; $i <= $nbr_entrees ; $i++)
{ //################################affichage_listing($resultat,$DB_link,($i -1));
$i--;
echo "<tr bgcolor=\"#CCCCCC\">";
// Selection
echo "<th align=left width=\"2%\" nowrap><input type= \"checkbox\" name =\"etat[]\" value =\"$i\" ></th>";
//Date
$tmp = mysql_result($resultat,$i,"date");
$tmp = $tmp."[".mysql_result($resultat,$i,"heure")."]";
echo "<th width=\"9%\" align=left nowrap>".$tmp."</th>";
//email
$tmp = mysql_result($resultat,$i,"email");
echo "<th width=\"12%\" align=left nowrap>".$tmp."</th>";
//Type de Message
if (mysql_result($resultat,$i,"reservation")) $tmp = "Reservation";
else $tmp = "Avis";
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th>";
//Message
$tmp = mysql_result($resultat,$i,"message");
echo "<th width=\"500\" align=left nowrap>".$tmp."</th>";
//Bouton Repondre
$j = $i +1;
echo "<th width=\"8%\" align=left nowrap><a href=\"repondre.php?indice=$i\"> <img src=\"images/Circle_Green.gif\" border =\"0\" width=\"12\" > [$j]</a></th>";
//Bouton Supprimer
//echo "<th width=\"8%\" align=left nowrap><a href=\"supprimer.php?indice=$i\"> Supprimer </a></th></tr>";
//################################}
$i++;
};
//for ($i = 11; $i <= $nbr_entrees ; $i++)
//{
//$indice = $i - 1;
//$delete_email = mysql_result($resultat,$indice,"email");
//$delete_heure = mysql_result($resultat,$indice,"heure");
//$requette2 = "delete from $table where email = '$delete_email' and heure = '$delete_heure'";
//mysql_db_query($database,$requette2,$DB_link);
//};
mysql_close($DB_link);
}
else affichage_unique("tbl vide");
?>
</form>
</table>
<p>---------------------------------------------------------------------------------------------------------------------------------------------------------------</p>
<p>Liste des indice selectionnés : </p>
<p>
<?php
if (isset($supprimer))
{
echo "SUP <br>";
};
if (isset($repondre))
{
echo "REP <br>";
};
for ($j = 0; $j < $nbr_entrees ; $j++)
if ($etat[$j] != "") echo " etat[$j]= $etat[$j] <br>";
?>
</body>
</html>
<?php
include("parametres.php");
$DB_link = mysql_connect($host,$user,"");
$requette = " select * from $table where actif = '1' order by date desc, heure desc ";
$resultat = mysql_db_query($database,$requette,$DB_link);
$nbr_entrees = mysql_num_rows($resultat);
$a = array();
function affichage_unique($var)
{
echo "<tr bgcolor=\"#CCCCCC\">";
//Date
$tmp = $var;
echo "<th width=\"10%\" align=left nowrap>".$tmp."</th>";
echo "<th width=\"12%\" align=left nowrap>".$tmp."</th>";
//Type de Message
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th>";
//Message
echo "<th width=\"500\" align=left nowrap>".$tmp."</th>";
//Bouton Repondre
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th>";
//Bouton Supprimer
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th></tr>";
};
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Listing des entrée dans la base : </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body { font-family: Verdana; font-size: 12px; font-weight: normal; color: #000000;}
A:link { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
A:active { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
A:visited { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
.title { font-family: Verdana; font-size: 14px; font-weight: bold; color: #404040; text-decoration: none;}
.menu { font-family: Verdana; font-size: 12px; font-weight: normal; color: #000000; text-decoration: none;}
.texte { font-family: Verdana; font-size: 12px; font-weight: normal; color: #000000; text-decoration: none;}
.com { font-family: Verdana; font-size: 12px; font-weight: bold; color: #000000}
.minitxt { font-family: Verdana; font-size: 9px; font-weight: normal; color: #000000; text-decoration: none;}
.minitxtred{ font-family: Verdana; font-size: 9px; font-weight: normal; color: #FF0000; text-decoration: none;}
.special { font-family: Verdana; font-size: 8px; font-weight: normal; color: #595959; text-decoration: none;}
--></style>
</head>
<body>
<table class="texte" width="100%" border=0 cellspacing=1 cellpadding=2>
<form name="listing" action="<?php echo $PHP_SELF;?>" method="post" >
<tr bgcolor="#FF8F15">
<td class="title" align=center colspan=6> <a class="minitxt" href="listing.php">Le
Sirroco Listing</a><br>
<a class="com" href="index.php">Retour
à la page d'accueil</a> : <a class="com" href="contact.php">Contact</a>
</td>
</tr>
<tr bgcolor="#FFEAD5">
<th align=left width="1%" nowrap></th>
<th align=left width="9%" nowrap>Date</th>
<th align=left width="15%" nowrap>Adresse mail/N° Tel</th>
<th align=left width="10%" nowrap>Type de message</th>
<th align=left width="40%" nowrap>Messages <input type="submit" name = "supprimer" value="Supprimer"> <input type="submit" name ="repondre" value="répondre"> </th>
<th align=left width="8%" nowrap> Statut</th>
</tr>
<?php
if ($nbr_entrees != 0)
{
for ($i = 1; $i <= $nbr_entrees ; $i++)
{ //################################affichage_listing($resultat,$DB_link,($i -1));
$i--;
echo "<tr bgcolor=\"#CCCCCC\">";
// Selection
echo "<th align=left width=\"2%\" nowrap><input type= \"checkbox\" name =\"etat[]\" value =\"$i\" ></th>";
//Date
$tmp = mysql_result($resultat,$i,"date");
$tmp = $tmp."[".mysql_result($resultat,$i,"heure")."]";
echo "<th width=\"9%\" align=left nowrap>".$tmp."</th>";
$tmp = mysql_result($resultat,$i,"email");
echo "<th width=\"12%\" align=left nowrap>".$tmp."</th>";
//Type de Message
if (mysql_result($resultat,$i,"reservation")) $tmp = "Reservation";
else $tmp = "Avis";
echo "<th width=\"8%\" align=left nowrap>".$tmp."</th>";
//Message
$tmp = mysql_result($resultat,$i,"message");
echo "<th width=\"500\" align=left nowrap>".$tmp."</th>";
//Bouton Repondre
$j = $i +1;
echo "<th width=\"8%\" align=left nowrap><a href=\"repondre.php?indice=$i\"> <img src=\"images/Circle_Green.gif\" border =\"0\" width=\"12\" > [$j]</a></th>";
//Bouton Supprimer
//echo "<th width=\"8%\" align=left nowrap><a href=\"supprimer.php?indice=$i\"> Supprimer </a></th></tr>";
//################################}
$i++;
};
//for ($i = 11; $i <= $nbr_entrees ; $i++)
//{
//$indice = $i - 1;
//$delete_email = mysql_result($resultat,$indice,"email");
//$delete_heure = mysql_result($resultat,$indice,"heure");
//$requette2 = "delete from $table where email = '$delete_email' and heure = '$delete_heure'";
//mysql_db_query($database,$requette2,$DB_link);
//};
mysql_close($DB_link);
}
else affichage_unique("tbl vide");
?>
</form>
</table>
<p>---------------------------------------------------------------------------------------------------------------------------------------------------------------</p>
<p>Liste des indice selectionnés : </p>
<p>
<?php
if (isset($supprimer))
{
echo "SUP <br>";
};
if (isset($repondre))
{
echo "REP <br>";
};
for ($j = 0; $j < $nbr_entrees ; $j++)
if ($etat[$j] != "") echo " etat[$j]= $etat[$j] <br>";
?>
</body>
</html>
plop!
Messages postés
54
Date d'inscription
jeudi 1 février 2007
Statut
Membre
Dernière intervention
16 mai 2007
27
2 févr. 2007 à 20:48
2 févr. 2007 à 20:48
Ca a l'air correct...
Essaie de me mettre le code HTML de ta page qui contient le formulaire, et fais un
Et donne le résultat
Essaie de me mettre le code HTML de ta page qui contient le formulaire, et fais un
print_r($_POST)après
for ($j = 0; $j < $nbr_entrees ; $j++) if ($etat[$j] != "") echo " etat[$j]= $etat[$j] <br>";
Et donne le résultat