salut a tous,
cela fait une journée que je cherche sans trouver le truc de base mais incompréhensible.
La bdd "test":
id | nom | position
1 | nom1 | 4
2 | nom2 | 3
3 | nom3 | 2
4 | nom4 | 1
le code :donc quand je valide mon "form", les données sont bien envoyées puisque je les affiches avec le print_r mais il ne trouve pas mon $id
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php require("connect.php"); if(!empty($_POST)) { $cate=$_POST['category']; foreach($cate as $c){ extract($c); print_r($c); $sql1="UPDATE test SET nom='$nom', position=$position WHERE id=$id"; mysql_query($sql1) or die(mysql_error()); } } ?> <!doctype html> <head> <meta charset="utf-8"> <title>jQuery UI Sortable - Default functionality</title> <link rel="stylesheet" href="js/jquery-ui.css"> <script src="js/jquery.js"></script> <script src="js/jquery-ui.js"></script> <script src="js/order.js"></script> <style> #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; } #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; } #sortable li span { position: absolute; margin-left: -1.3em; } ul#sortable li{border:1px solid #ff0000} ul#sortable li.fantom{border:1px solid #000000} </style> </head> <body> <form method="post" action="admin.php"> <ul id="sortable"> <?php $i=0; $sql="SELECT nom,id,position FROM test ORDER BY position ASC"; $req = mysql_query($sql) or die(mysql_error()); while($d = mysql_fetch_assoc($req)) { $i++; ?> <li> <span class="ui-icon ui-icon-arrowthick-2-n-s"></span> <input type="hidden" name="category[<?php echo $i; ?>][$id]" value="<?php echo $d['id'];?>" /> <input type="text" name="category[<?php echo $i; ?>][$nom]" value="<?php echo $d['nom'];?>" /> <input type="text" class="positioninput" name="category[<?php echo $i; ?>][$position]" value="<?php echo $d['position'];?>" /> </li> <?php } ?> </ul> <input type="submit" value="Enregistrer"/> </form> </body> </html>
cela m'affiche cette erreur
si qql'un a une idée je suis preneur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part Array ( [$id] => 1 [$nom] => Titre1 [$position] => 4 ) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id=' at line 1
merci d'avance
Partager