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
| <?php
$base = include 'include/connect.inc.php';
$resultat = $base->query('
SELECT atm.`ID_texte`, atm.`ID_metal`, m.`ID_metal`, m.`nom_metal`
FROM AS_TEXTE_METAL atm, METAL m
WHERE atm.`ID_metal` = m.`ID_metal`
AND atm.`ID_texte` = "'.$_SESSION['ID_texte'].'"
') or die($mysqli->error.__LINE__);
while($row = $resultat->fetch()) { $arr[] = $row; }
// transformation de la chaîne en tableau
$metal_array = explode(',', $row['nom_metal']);
foreach($metal_array as $valeur) {
?>
<?php if (in_array("$metal_array[0]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="1" <?php echo $check; ?> />
argent
<?php if (in_array("$metal_array[1]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="2" <?php echo $check; ?> />
bronze
<?php if (in_array("$metal_array[2]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="5" <?php echo $check; ?> />
cuivre
<?php if (in_array("$metal_array[3]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="8" <?php echo $check; ?> />
étain
<?php if (in_array("$metal_array[4]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="9" <?php echo $check; ?> />
fer
<?php if (in_array("$metal_array[5]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="10" <?php echo $check; ?> />
or
<?php if (in_array("$metal_array[6]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="11" <?php echo $check; ?> />
plomb
<?php if (in_array("$metal_array[7]", $metal_array)) { $check = "checked"; } else { $check = ''; } ?> <input name="metal[]" type="checkbox" value="12" <?php echo $check; ?> />
autre
<?php
}
?> |
Partager