Bonjour,
Je génère un tableau automatiquemenet à partir d'une de mes tables, du type id_produit, id_mois, valeur
Dans la colonne de gauche, j'ai mes produits (id_produits).
Dans la ligne du haut, j'ai les 12 mois de l'année (id_mois).
Dans les cellules, j'ai le coût d'un produit pour un mois donné (valeur).
Je souhaite pouvoir modifier une ou plusieurs cellules en même temps, c'est-à-dire updater ma table lorsque j'envoies le formulaire.
Seulement, je ne sais pas comment récupérer les trois informations pour pouvoir faire les update.
Dois-je utiliser des hidden ?
Merci beaucoup pour votre aide.
Voici mon code :
<body>
<form name="form_add" method="post" action="reporting_add.php">
<input type="submit" value="save">
<table width="100%" cellpadding="0" cellspacing="1" border="0" class="td_small">
<tr>
<td width="100%">
<?php
$table_values = get_values();
?>
<table width="0" cellpadding="3" cellspacing="3" border="0">
<tr>
<td> </td>
<?php
foreach($table_values as $month => $value_month) {
?>
<td width="40" align="center">
<?php
if ($month == 1) { $month = 'jan'; }
if ($month == 2) { $month = 'feb'; }
if ($month == 3) { $month = 'mar'; }
if ($month == 4) { $month = 'apr'; }
if ($month == 5) { $month = 'may'; }
if ($month == 6) { $month = 'jun'; }
if ($month == 7) { $month = 'jul'; }
if ($month == 8) { $month = 'aug'; }
if ($month == 9) { $month = 'sep'; }
if ($month == 10) { $month = 'oct'; }
if ($month == 11) { $month = 'nov'; }
if ($month == 12) { $month = 'dec'; }
echo $month;
?>
</td>
<?php
}
?>
</tr>
<?php
foreach(reset($table_values) as $ia => $value_ia) {
$query_list_ia = mysql_query("SELECT name FROM tbl_ia WHERE id = $ia");
$retrieval_list_ia = mysql_fetch_array($query_list_ia);
?>
<tr>
<td width="70" class="fviolet_pgrasse">
<?php
echo stripslashes(htmlentities($retrieval_list_ia['name']));
?>
</td>
<?php
foreach($table_values as $month => $value_month) {
?>
<td align="center">
<input name="value[]" type="text" class="zdt_04" value="<?php echo $value_month[$ia]; ?>">
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</form>
</body>