Php et mysql

Fermé
Zedrof Messages postés 156 Date d'inscription mercredi 27 août 2014 Statut Membre Dernière intervention 9 juin 2022 - 31 oct. 2014 à 13:16
Zedrof Messages postés 156 Date d'inscription mercredi 27 août 2014 Statut Membre Dernière intervention 9 juin 2022 - 2 nov. 2014 à 16:54
bonjour,
en faite j suis entrain de travaille sur un projet la ou j dois vraiment essaye de rendre dynamique mes boutons Action(delete,edit,consulte et update) vraiment il ne sont pas.
essaye qlq peut m'a me depanne
code edit:
<?php


$req = "select * from division ";
$requete= $connexion->prepare($req);
$requete->execute();

$division=$requete->fetch(PDO::FETCH_OBJ);




?>
<h2 align="center"> Modification des division de RMCR </h2>
<form class="formulaire" action="index.php?page=modules/division/update.php" method="post"><br/>
<label><strong> Numero division : </strong></label>
<input type="text" readonly name="numdiv" value="<?php echo $division->numdiv ?>" /><br/>
<br/><br/>
<label><strong>Nom division: </strong></label>
<input type="text" name="nomuser" value="<?php echo $division->nomdiv ?>" /><br/>
<br/><br/>
<label><strong> Numero departement : </strong></label>
<select name="numdept" value="<?php echo $division->numdept ?>" >
<option value="0"></option>
<?php
while($departement=$requete->fetch(PDO::FETCH_OBJ)){
?>

<option value="" >
<?php echo $departement->numdept ?>

</option>
<?php } ?>
</select><br/>


<br/><br/>
<input name="annuler" type ="reset" value="Annuler"/>
<input name="valider" type ="submit" value="Valider"/>
</form>

Code update:
<?php

$numdiv= $_POST['numdiv'];
$nomdiv= $_POST['nomdiv'];
$numdept= $_POST['numdept'];
try{


$req= $connexion->prepare ("update division set
nomdiv=:nomdiv,
numdept=:numdept
where numdiv=:numdiv");
$req->bindParam(':nomdiv', $nomdiv,PDO::PARAM_STR);
$req->bindParam(':numdept', $numdept,PDO::PARAM_INT);
$req->bindParam(':numdiv', $numdiv,PDO::PARAM_INT);

$req->execute();
//$connexion->exec($req);

echo"<div numdept='message'><strong> Modification effectuée avec succes </strong></div>";

include "modules/division/index.php";

}
catch (Exception $e){
echo $e->message;
}
Code supprimer:
<?php
include '../../config/connexion.php';
$numdiv = $_POST['numdiv'];

$res = $connexion->exec("delete from division where numdiv=$numdiv");
if($res === FALSE)
{
echo " <div numdiv='message_erreur'><strong> Erreur lors de la suppréssion!! </strong></div>";
}
else
{
echo " <div numdiv='message'><strong> Suppréssion effèctuée avec succès </strong></div>";
}

include 'index.php'
?>
Code consulter:
<?php


$req = "select * from division";
$requete= $connexion->prepare($req);
$requete->execute();
$ligne=$requete->fetch(PDO::FETCH_OBJ);
?>

<h2 align="center"> Reférence de la division </h2>

<table class="liste_consulter">
<tr>
<th><strong> Numero division </strong> </th>
<th><strong> Nom division </strong> </th>
<th><strong> Numero departement </strong> </th>

</tr>
<tr>
<td> <?php echo $ligne->numdiv ?> </td>
<td> <?php echo $ligne->nomdiv ?></td>
<td> <?php echo $ligne->numdept ?></td>
</tr>
</table>
<br/>
<form id="retour" action="index.php?page=modules/division/index.php" method="">
<input id ="valider" name="valider" type ="submit" value="Retour" />
</form>
COde de l'index:
<?php
while ($ligne=$requete->fetch(PDO::FETCH_OBJ)){
?>
<tr>

<td ><?php echo $ligne->numdiv?></td>
<td ><?php echo $ligne->nomdiv?></td>
<td ><?php echo $ligne->nomdept?></td>

<td>
<a href="index.php?page=modules/division/consulter.php&id=<?php echo $ligne->numdiv?>">

<img src="web/images/consulter.png" width="" height="">

</a>

<a href="index.php?page=modules/division/edit.php&id=<?php echo $ligne->numdiv?>">

<img src="web/images/modifier.png" width="" height="">
</a>

<a href="#">
<span onclick="if(confirm('voulez vous supprimer cet division ?')) mettreAjourDiv('modules/division/suppression.php','corps', '<?php echo $ligne->numdiv ?>')">
<img src="web/images/supprimer.png" width="" height="" title="">

</span>
</a>

</td>
</tr>

<?php
}
?>

</table>



SVP vraiment c'est important pour moi
A voir également:

2 réponses

thekiing Messages postés 49 Date d'inscription samedi 20 novembre 2010 Statut Membre Dernière intervention 1 novembre 2014 40
1 nov. 2014 à 13:46
Salut,

Il ne faut pas mettre d'espace entre type et submit (dans le code des boutons) :
type="submit"
et non pas
type ="submit" 

0
Zedrof Messages postés 156 Date d'inscription mercredi 27 août 2014 Statut Membre Dernière intervention 9 juin 2022 1
2 nov. 2014 à 16:54
bsr merci j vais tenir compte de ça
0