$sql="SELECT * FROM WHERE identifiant=$_GET['id']";
$id = $_GET['id']; $sql "SELECT * FROM [NOM_TABLE] WHERE identifiant ".$id.";
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question$id = $_GET['id']; $sql "SELECT * FROM [NOM_TABLE] WHERE identifiant ".$id;
J'ai une petite question qui pourrait peut-être paraitre debile mais le javascript c'est obligé qu'il soit dans la partie <head></head>??parce que je vois dans le script que tu ma conseillée d'étudier, le javascript n'ai pas dans la partie <head></head>...
on ma trouvée une faute sur ma requête :
Code PHP :
$sql="SELECT * FROM WHERE identifiant=$_GET['id']";
Ma faute parait-il c'est : Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\Gestion_dun_parc_informatique\index.php on line 125
<?php $toto = "moto"; $sql="SELECT * FROM WHERE identifiant=$toto"; echo $sql; // Donne // SELECT * FROM WHERE identifiant=moto ?>
<?php $toto['hello'] = "moto"; $sql="SELECT * FROM WHERE identifiant=".$toto['hello']; echo $sql; // Donne // SELECT * FROM WHERE identifiant=moto ?>
<?php $sql='SELECT * FROM WHERE identifiant="'.mysql_real_escape_string($toto['hello']).'"'; echo $sql; // Donne // SELECT * FROM WHERE identifiant="moto" // Avec moto sécurisé... Pour plus de details cf lien "mysql_real_escape_string" ci dessous ?>
<?php // Si on appel mapage.php pour ajouter un element // avec la variable d'url action et la valeur add // mapage.php?action= add if(isset($_GET['action']) and $_GET['action'] == 'add') { ?> <!-- Créer formulaire d ajout --> <?php } // Si on appel mapage.php pour éditer un element // avec la variable d'url action et la valeur edit // mapage.php?action=edit&id=NUM elseif(isset($_GET['action']) and $_GET['action'] == 'edit') { // SELECT * FROM table WHERE identifiant=$_GET['id'] ?> <!-- Créer formulaire de modification --> <?php } // Si on appel mapage.php pour supp un element // avec la variable d'url action et la valeur del // mapage.php?action=del&id=NUM // ou // mapage.php?action=del avec la var post choix elseif(isset($_GET['action']) and $_GET['action'] == 'del') { // Si l user clique sur un lien supprimé, il charge cette page avec l'information de suppression dans la variable d url id if(isset($_GET['id'])) { // DELETE WHERE identifiant=$_GET['id'] } // Si il clique en soumettant le formulaire (Bouton supprimer) c'est alors la variable POST choix qui contiendras un tableau des ID cochées elseif(isset($_POST['choix'])) { // Pour chaque choix dans le tableau $_POST['choix'] // DELETE WHERE identifiant=valeur choix } // Redirection vers mapage.php } else { // Si on appel mapage.php sans variables ?> <form id="Formulaire" name="Formulaire" method="post" action="mapage.php?action=del"> | Date installation | Identifiant | Nom PC | Affectation | Agence | Users | Mot_de_passe | Adresse IP | Raccordement domaine | Création Users | Base MP | MP_Intranet | MAJ_MP | Office | Symantec | VNC | Adobe Reader | Config. Boîte email | PDF Creator | <?php while ($tab = mysql_fetch_array($res)) { ?> ---- ">, <?php echo $tab['date_installation'];?>, <?php echo $tab['identifiant'];?>, <?php echo $tab['nom_pc'];?>, <?php echo $tab['affectation'];?>, <?php echo $tab['agence'];?>, <?php echo $tab['users'];?>, <?php echo $tab['mot_de_passe'];?>, <?php echo $tab['adresse_ip'];?>, <?php echo $tab['raccordement_domaine'];?>, <?php echo $tab['creation_users'];?>, <?php echo $tab['base_mp'];?>, <?php echo $tab['mp_intranet'];?>, <?php echo $tab['maj_mp'];?>, <?php echo $tab['office'];?>, <?php echo $tab['symantec'];?>, <?php echo $tab['vnc'];?>, <?php echo $tab['adobe_reader'];?>, <?php echo $tab['config_boite_mail'];?>, <?php echo $tab['pdf_creator'];?>, ---- [mapage.php?action=add Ajouter] | [javascript:; Supprimer] </center> </form> <script type="text/javascript"> <!--// J Ai pas vérifier si ca marche... :-D function checkUcheckAll(toCheck) { var mesCheck = document.Formulaire.choix; if(toCheck) { for (var i=0; i<mesCheck.length; i++) { mesCheck[i].checked = 'checked'; } } else { for (var i=0; i<mesCheck.length; i++) { mesCheck[i].checked = ''; } } } // --> </script> <?php } ?>
<form id="Formulaire" name="Formulaire" method="post" action="mapage.php?action=del">
$id = $_GET['id']; $sql "SELECT * FROM ordinateur WHERE identifiant ".$id; $res = mysql_query($sql) or die (); $total = mysql_num_rows($res);
<!-- Formulaire de modification --> <table> <tr> <th colspan="2">MODIFICATION FICHE INSTALLATION ORDINATEUR<th> </tr> <tr> <td>Date installation :</td> <td></td> </tr> <tr> <td>Identifiant :</td> <td ></td> </tr> <tr> <td>Nom PC :</td> <td></td> </tr> <tr> <td>Affectation :</td> <td></td> </tr> <tr> <td>Agence :</td> <td></td> </tr> <tr> <td>Users :</td> <td></td> </tr> <tr> <td>Mot de passe :</td> <td></td> </tr> <tr> <td>Adresse IP :</td> <td></td> </tr> <?php } // Si on appel mapage.php pour supprimer un element avec la variable d'url action et la valeur del mapage.php?action=del&id=NUM ou mapage.php?action=del avec la var post choix elseif(isset($_GET['action']) and $_GET['action'] == 'del') { // Si l user clique sur un lien supprimé, il charge cette page avec l'information de suppression dans la variable d url id if(isset($_GET['id'])) { $sql2="DELETE WHERE identifiant= ".$id; } // Si il clique en soumettant le formulaire (Bouton supprimer) c'est alors la variable POST choix qui contiendras un tableau des ID cochées elseif(isset($_POST['choix'])) { // Pour chaque choix dans le tableau $_POST['choix'] $sql3=" DELETE WHERE identifiant=valeur choix"; } // Redirection vers mapage.php } else { // Si on appel mapage.php sans variables ?> <form id="Formulaire" name="Formulaire" method="post" action="mapage.php?action=del"> <table border="1"> <tr> <th></th> <th>Date installation</th> <th>Identifiant</th> <th>Nom PC</th> <th>Affectation</th> <th>Agence</th> <th>Users</th> <th>Mot_de_passe</th> <th>Adresse IP</th> <th>Raccordement domaine</th> <th>Création Users</th> <th>Base MP</th> <th>MP_Intranet</th> <th>MAJ_MP</th> <th>Office</th> <th>Symantec</th> <th>VNC</th> <th>Adobe Reader</th> <th>Config. Boîte email</th> <th>PDF Creator</th> </tr> <?php while ($tab = mysql_fetch_array($res)) { ?>
<html> <head> <meta http-equiv= "Content-Type" content="text/html; charset=iso-8859-1"> <title>Gestion parc informatique - Ajouter</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <hr> <?php // Si on appel mapage.php pour modifier un element avec la variable d'url action et la valeur edit mapage.php?action=edit&id=NUM elseif(isset($_GET['action']) and $_GET['action'] == 'edit') { $id = $_GET['id']; $sql "SELECT * FROM ordinateur WHERE identifiant ".$id; $res = mysql_query($sql) or die (); $total = mysql_num_rows($res); ?> <!-- Formulaire de modification --> MODIFICATION FICHE INSTALLATION ORDINATEUR | ---- Date installation :, , ---- Identifiant :, , ---- Nom PC :, , ---- Affectation :, , ---- Agence :, , ---- Users :, , ---- Mot de passe :, , ---- Adresse IP :, , <?php } // Si on appel mapage.php pour supprimer un element avec la variable d'url action et la valeur del mapage.php?action =del&id= NUM ou mapage.php?action=del avec la var post choix elseif(isset($_GET['action']) and $_GET['action'] == 'del') { // Si l user clique sur un lien supprimé, il charge cette page avec l'information de suppression dans la variable d url id if(isset($_GET['id'])) { $sql2=\"DELETE WHERE identifiant= \".$id; } // Si il clique en soumettant le formulaire (Bouton supprimer) c'est alors la variable POST choix qui contiendras un tableau des ID cochées elseif(isset($_POST['choix'])) { // Pour chaque choix dans le tableau $_POST['choix'] $sql3=\" DELETE WHERE identifiant=valeur choix\"; } // Redirection vers mapage.php } else { // Si on appel mapage.php sans variables ?> <form id=\"Formulaire\" name=\"Formulaire\" method=\"post\" action=\"mapage.php?action=del\"> <table border=\"1\"> ---- | Date installation | Identifiant | Nom PC | Affectation | Agence | Users | Mot_de_passe | Adresse IP | Raccordement domaine | Création Users | Base MP | MP_Intranet | MAJ_MP | Office | Symantec | VNC | Adobe Reader | Config. Boîte email | PDF Creator | <?php while ($tab = mysql_fetch_array($res)) { ?> ---- ">, <?php echo $tab['date_installation'];?>, <?php echo $tab['identifiant'];?>, <?php echo $tab['nom_pc'];?>, <?php echo $tab['affectation'];?>, <?php echo $tab['agence'];?>, <?php echo $tab['users'];?>, <?php echo $tab['mot_de_passe'];?>, <?php echo $tab['adresse_ip'];?>, <?php echo $tab['raccordement_domaine'];?>, <?php echo $tab['creation_users'];?>, <?php echo $tab['base_mp'];?>, <?php echo $tab['mp_intranet'];?>, <?php echo $tab['maj_mp'];?>, <?php echo $tab['office'];?>, <?php echo $tab['symantec'];?>, <?php echo $tab['vnc'];?>, <?php echo $tab['adobe_reader'];?>, <?php echo $tab['config_boite_mail'];?>, <?php echo $tab['pdf_creator'];?>, ---- [ajout.php Ajouter] | [javascript:; Supprimer] </center> </form> <script type="text/javascript"> <!--// J Ai pas vérifier si ca marche... :-D function checkUcheckAll(toCheck) { var mesCheck = document.Formulaire.choix; if(toCheck) { for (var i=0; i<mesCheck.length; i++) { mesCheck[i].checked = 'checked'; } } else { for (var i=0; i<mesCheck.length; i++) { mesCheck[i].checked = ''; } } } // --> </script> <?php } ?> </html>
$res = mysql_query($sql) or die (); $total = mysql_num_rows($res);