1 pièce(s) jointe(s)
formulaire selection d une ligne et envoi de son $id
bonjours,
c'est encore moi ^^
je vous écrit pour un petite demande d'orientation pour résoudre un soucis vis a vis d'un formulaire.
Mon soucis étant que j'ai un tableau qui lit un tableau bidimensionnelle et renvoie les valeur de chaque ligne de chaque colonne.
et j' ai tenter un système pour que l'on puisse sélectionne une ligne précise ( en mettant une checkbox) et que celle-ci renvoie le numéro de la ligne lu.
Cela fonctionner jusqu’à présent mais la d'un coup cela ne fonctionne plus et je ne comprend pas pourquoi '-'.
en effet au lieu de m'afficher tout mes choix, cela ne m'affiche plus que ma dernière ligne meme si je ne la sélectionne pas '-'.
et cela meme si je sélectionne plusieurs lignes.
Pièce jointe 210117
si quelqu'un pouvais m'oriente je lui en serais grès :)
voici mon code de formulaire
Code:
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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
| <form name="selection" id="selection" action="../achat/selection.php" method="post" enctype="multipart/form-data" target="ma_popup" onsubmit="window.open('', 'ma_popup', 'toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=350'); this.submit();">
<table width="100%"style="color=#FFFFFF">
<tr style="height: 16px" align="center">
<td>
<font class="font_p" color="#5d8eb3">
<b>
#
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
image
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
nom_du_jeu
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
date_sortie
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
nbr de joueurs
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
prix
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
quant dispo
</b>
</font>
</td>
<td >
<font class="font_p" color="#5d8eb3">
<b>
acheter
</b>
</font>
</td>
</tr>
<!------------------------------------------------------------------------------------------------------------------------------------>
<!-- fin de l'entete de notre tableau -->
<!------------------------------------------------------------------------------------------------------------------------------------>
<?php
//<!------------------------------------------------------------------------------------------------------------------------------------>
//<!-- on compte le nombre de lignes dans le fichier texte -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
$nb_elements = count($data);
$nb_lignes= $nb_elements;
//<!------------------------------------------------------------------------------------------------------------------------------------>
//<!-- on ouvre une boucle 'for' qui tournera autant de fois qu'il y a de lignes dans le fichier texte -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
for ($i = 0; $i < $nb_lignes; $i ++)
{
$new_ligne= array();
$new_ligne[0]= $data[$i]['id'];
$new_ligne[1]= $data[$i]['nom_du_jeu'];
$new_ligne[2]= $data[$i]['date_sortie'];
$new_ligne[3]= $data[$i]['image'];
$new_ligne[4]=$data[$i]['nbr de joueurs'];
$new_ligne[5]= $data[$i]['prix'];
$new_ligne[6]= $data[$i]['quantite'];
$id=$new_ligne[0];
$nom_du_jeu=$new_ligne[1];
$date=$new_ligne[2];
$image=$new_ligne[3];
$joueurs=$new_ligne[4];
$prix=$new_ligne[5];
$stock=$new_ligne[6];
//<!------------------------------------------------------------------------------------------------------------------------------------>
// <!-- Définition de la position à afficher -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
//<!-- on affiche les infos des jeux dans chaque ligne du tableau-->
//<!------------------------------------------------------------------------------------------------------------------------------------>
if($stock > 0)
{
?>
<tr style="height: 16px" align="center">
<td class="font_p">
<?php
echo
isset($id) ?
"<FONT color='white'>".$id : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($image) ?
"<img src=\" ".$image."\">" : ''
;
?>
</td>
<td>
<?php
echo
isset($nom_du_jeu) ?
"<FONT color='white'>".$nom_du_jeu : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($date) ?
"<FONT color='white'>".$date : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($joueurs) ?
"<FONT color='white'>".$joueurs : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($prix) ?
"<FONT color='white'>".$prix."" : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($stock) ?
"<FONT color='white'>".$stock : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
"<input type='checkbox' name='id[]' value='".$id."'>"
;
?>
</td>
</tr>
<?php
}
else
{
?>
<tr style="height: 16px" align="center">
<td class="font_p">
<?php
echo
isset($id) ?
"<FONT color='white'>".$id : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($image) ?
"<img src=\" ".$image."\">" : ''
;
?>
</td>
<td>
<?php
echo
isset($nom_du_jeu) ?
"<FONT color='white'>".$nom_du_jeu : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($date) ?
"<FONT color='white'>".$date : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($joueurs) ?
"<FONT color='white'>".$joueurs : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($prix) ?
"<FONT color='white'>".$prix."" : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($stock) ?
"<FONT color='white'>".$stock : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
"<FONT color='red'>rupture de stock</FONT>"
;
?>
</td>
</tr>
<?php
}
}
//<!------------------------------------------------------------------------------------------------------------------------------------>
// <!-- Fin de la boucle for -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
?>
<tr style="height: 16px" align="center">
<td colspan=8>
<input type="submit" value="Envoyer" name="select"/ onClick="valider()">
</td>
</tr>
</table>
</form> |
et le code de la fenetre
Code:
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
| <form name="selection" id="achat" action="../achat/panier.php" method="post" enctype="multipart/form-data">
<table width="100%"style="color=#FFFFFF">
<thead>
<tr style="height: 16px" align="center">
<td>
<font class="font_p" color="#5d8eb3">
<b>
image
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
nom_du_jeu
</b>
</font>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
prix
</b>
</font>
</td>
<td >
<font class="font_p" color="#5d8eb3">
<b>
confirmer achat
</b>
</font>
</td>
</tr>
</thead>
<!------------------------------------------------------------------------------------------------------------------------------------>
<!-- fin de l'entete de notre tableau -->
<!------------------------------------------------------------------------------------------------------------------------------------>
<?php
//<!------------------------------------------------------------------------------------------------------------------------------------>
//<!-- on compte le nombre de lignes dans le fichier texte -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
$nb_elements = count($data);
$nb_lignes= $nb_elements;
//<!------------------------------------------------------------------------------------------------------------------------------------>
//<!-- on ouvre une boucle 'for' qui tournera autant de fois qu'il y a de lignes dans le fichier texte -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
for ($i = 0; $i < $nb_lignes; $i ++)
{
$new_ligne= array();
$new_ligne[0]= $data[$i]['id'];
$new_ligne[1]= $data[$i]['nom_du_jeu'];
$new_ligne[2]= $data[$i]['prix'];
$new_ligne[3]= $data[$i]['image'];
$total= array();
$total[$i]=$data[$i]['prix'];
$id=$new_ligne[0];
$image=$new_ligne[3];
$nom_du_jeu=$new_ligne[1];
$prix=$new_ligne[2];
//<!------------------------------------------------------------------------------------------------------------------------------------>
// <!-- Définition de la position à afficher -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
//<!-- on affiche les infos des jeux dans chaque ligne du tableau-->
//<!------------------------------------------------------------------------------------------------------------------------------------>
?> <tbody>
<tr style="height: 16px" align="center">
<td>
<?php
echo
isset($image) ?
"<img src=\" ".$image."\">" : ''
;
?>
</td>
<td>
<?php
echo
isset($nom_du_jeu) ?
"<FONT color='black'>".$nom_du_jeu : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
isset($prix) ?
"<FONT color='black'>".$prix."" : ''. "</FONT>"
;
?>
</td>
<td>
<?php
echo
"<input type='checkbox' name='id[]' value='".$id."'>"
;
?>
</td>
</tr>
<?php
}
//<!------------------------------------------------------------------------------------------------------------------------------------>
// <!-- Fin de la boucle for -->
//<!------------------------------------------------------------------------------------------------------------------------------------>
?>
</tbody>
<tfoot>
<tr style="height: 16px" align="center">
<td colspan=3>
</td>
<td>
<font class="font_p" color="#5d8eb3">
<b>
total
</b>
</font>
</td>
</tr>
<tr style="height: 16px" align="center">
<td colspan=3>
<input type="submit" value="confirmer" name="select"/ onClick="valider()">
</td>
<td>
<?php
echo
array_sum($total) . "\n"
;
?>
</td>
</tr>
</tfoot>
</table> |