Bonjour a tous,
Voila le problème es qu'en faite je veux crée une table modifiable en pages php donc 5 pages son crée
ajout.php ( fonctionne )
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 <html> <head> <title>tabcharg_ajou</title> <head> <body> Ajouter :<br> <form method="post" action="ajoutok.php"> service : <select name="service" id="service"> <option value="repas">repas</option> <option value="hotel">hotel</option> <option value="banque">banque</option> </select><br/> descriptif : <input type="text" name="descriptif"><br> membre : <select name="membre" id="membre"> <option value="Justin">Justin</option> <option value="nicola">nicola</option> </select><br/> action : <select name="act" id="act"> <option value="En attente">En attente</option> <option value="En cours">En cours</option> <option value="Fini">Fini</option> </select><br/> <input type="submit" name="submit" value="Insérer"> </form> </body> </html>
ajoutok.php ( fonctionne )
list.php ( fonctionne )Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <?php if (isset($_POST['service'], $_POST['descriptif'], $_POST['membre'], $_POST['act'])) { $connect = mysql_connect('localhost','root','') or die ("erreur de connexion"); mysql_select_db('base',$connect) or die ("erreur de connexion base"); $service = mysql_real_escape_string($_POST['service']); $descriptif = mysql_real_escape_string($_POST['descriptif']); $membre = mysql_real_escape_string($_POST['membre']); $act = mysql_real_escape_string($_POST['act']); mysql_query(" INSERT INTO `table` (service, descriptif, membre, action ) VALUES ('$service', '$descriptif', '$membre', '$act'); " ) or die ( mysql_error() ); } else{ echo '<h4>Tous les champs sont obligatoire</h4>'; } ?>
modification1.phpCode:
1
2
3
4
5
6
7
8
9
10
11
12 <?php $db = mysql_connect('localhost', 'root', ''); mysql_select_db('base',$db); $sql = 'SELECT service,descriptif,membre,action FROM tcharge'; $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); while($data = mysql_fetch_assoc($req)) { echo '<b>'.$data['service'].' '.$data['descriptif'].'</b> ('.$data['membre'].')'; echo ' '.$data['action'].'</i><br>'; } mysql_close(); ?>
modification2.phpCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 <html> <head> <title>modification</title> </head> <body> <?php $cnx = mysql_connect( "localhost", "root", "" ) ; $db = mysql_select_db( "base" ) ; $sql = "SELECT * FROM table ORDER BY id" ; $requete = mysql_query( $sql, $cnx ) ; while( $result = mysql_fetch_object( $requete ) ) { echo( "<div align=\"center\">" .$result->service." ".$result->action ." <a href=\"modification2.php?idPersonne=".$result->id."\">modifier</a></div>\n" ) ; } ?> </body> </html>
modification3.phpCode:
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 <html> <head> <title>modification de données en PHP :: partie2</title> </head> <body> <?php $cnx = mysql_connect( "localhost", "root", "" ) ; $db = mysql_select_db( "base" ) ; $id = $_GET["idPersonne"] ; $sql = "SELECT * FROM table WHERE id = ".$id ; $requete = mysql_query( $sql, $cnx ) ; while( $result = mysql_fetch_object( $requete ) ) { ?> <form name="insertion" action="modification3.php" method="POST"> <input type="hidden" name="id" value="<?php echo($id) ;?>"> <table border="0" align="center" cellspacing="2" cellpadding="2"> <tr align="center"> <td>service</td> <td><input type="text" name="service" value="<?php echo($result->service) ;?>"></td> </tr> <tr align="center"> <td>descriptif</td> <td><input type="text" name="descriptif" value="<?php echo($result->descriptif) ;?>"></td> </tr> <tr align="center"> <td>membre</td> <td><input type="text" name="membre" value="<?php echo($result->membre) ;?>"></td> </tr> <tr align="center"> <td>action</td> <td><input type="text" name="action" value="<?php echo($result->action) ;?>"></td> </tr> <tr align="center"> <td colspan="2"><input type="submit" value="modifier"></td> </tr> </table> </form> <?php } ?> </body> </html>
Le problème vient des page de modification j'ai suivi cela sur un tuto mes il ne fonctionne pas !! Quelqu'un pourrait m'aider sur se sujet je voudrai un tableaux de ma table de donnée ou je pourrais en modifier le contenu de manière simple !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 <?php $cnx = mysql_connect( "localhost", "root", "" ) ; $db = mysql_select_db( "base" ) ; $service = $_POST["service"] ; $descriptif = $_POST["descriptif"] ; $membre = $_POST["membre"] ; $action = $_POST["action"] ; $id = $_POST["id"] ; $sql = "UPDATE table SET service = '$service', descriptif = '$descriptif', membre = '$membre', action = '$action', WHERE id = '$id' " ; $requete = mysql_query($sql, $cnx) or die( mysql_error() ) ; if($requete) { echo("La modification à été correctement effectuée") ; } else { echo("La modification à échouée") ; } ?>
est t'il possible de faire une sélection sur un id qui es en auto-incrément et suivre avec un update ?