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
| <?php
include('../includes/fonctions.inc.php');
// Suggestion :
//error_reporting(-1); // pour voir toutes les erreurs
//Modification note
if (isset($_POST['ok'])) {
// var_dump($_POST); // voir toutes les données POST
$sql = "UPDATE note SET
idelevenote='{$_POST['id_eleve']}',
matierenote='{$_POST['matieren']}',
note1='{$_POST['note1']}',
note2='{$_POST['note2']}',
note3='{$_POST['note3']}',
compo1='{$_POST['compo1']}',
trim1=''
WHERE idnote='{$_POST['id_note']}' "; // risque d'injection SQL
if ($result = mysql_query($sql)) {
// guillemets simples
echo '<script type="text/javascript">
alert("Note modifiée");
</script>';
// attention header mal placé, tu as un echo avant
header('Location: note.php');
} else {
// encore guillemets simples
echo '<script type="text/javascript">
alert("Erreur, vérifiez vos paramètres");
</script>';
}
}
//requête de recuperation
if (isset($_POST['id'])) // accolades ?
$req = mysql_query("SELECT * FROM note WHERE idelevenote ='{$_POST['id']}' ");
$sql2 = mysql_query("SELECT * FROM note WHERE idelevenote ='{$_POST['id']}' ");
if (!mysql_num_rows($sql2)) {
// guillemets simples
echo 'Pas de notes disponibles';
// encore un header mal placé
header('Location: noteInscription.php');
} else {
//while ($note = mysql_fetch_array($sql2)) {
?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>UPDATE-NOTE</title>
<style>
/* Un peu de CSS pour nettoyer le code HTML des attributs align,
width, height, etc. */
table {
width: 500px;
margin: auto;
border-collapse: collapse;
}
th {
width: 38.2%;
text-align: right;
}
th, td {
padding: 0.25ex 1ex;
}
tbody {
border-top: solid 2px #666;
}
td[colspan=2] {
text-align: right;
padding: 1ex;
}
</style>
</head>
<body>
<form method="POST" name="noteup" action="developez.php">
<table>
<thead>
<tr>
<th scope="col">id_eleve</th>
<td>
<input type="hidden" name="id_eleve" value="<?php echo $req['idelevenote']; ?>" />
<?php echo $req['idelevenote']; ?>
</td>
</tr>
</thead>
<?php
$i = 0;
while ($note = mysql_fetch_array($sql2)) {
// ici guillemets doubles car il y a des variables
echo "<tbody>
<tr>
<th scope='row'>idnote</th>
<td><input type='hidden' name='id_note_$i' value='{$note['idnote']}' />{$note['idnote']}</td>
</tr>
<tr>
<th scope='row'>Matière</th>
<td><input type='hidden' name='matieren_$i' value='{$note['matierenote']}' />{$note['matierenote']}</td>
</tr>
<tr>
<th scope='row'>Note 1</th>
<td><input name='note1_$i' value='{$note['note1']}' />{$note['note1']}</td>
</tr>
<tr>
<th scope='row'>Note 2</th>
<td><input name='note2_$i' value='{$note['note2']}' />{$note['note2']}</td>
</tr>
<tr>
<th scope='row'>Note 3</th>
<td><input name='note3_$i' value='{$note['note3']}' />{$note['note3']}</td>
</tr>
<tr>
<th scope='row'>Compo 1</th>
<td><input name='compo1_$i' value='{$note['compo1']}' />{$note['compo1']}</td>
</tr>
<tr>
<th scope='row'>trim1</th>
<td><input name='trim1_$i' value='{$note['trim1']}' />{$note['trim1']}</td>
</tr>
<tr>
<td colspan='2'><input type='submit' name='ok' value='Envoyer' /></td>
</tr>
</tbody>";
$i++;
}
//}
} ?>
<tbody>
<tr>
<td colspan="2">
<input type="submit" name="ok" value="Tout envoyer">
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html> |
Partager