Bonjour a tous,
je suis en formation informatique et j'essaie de comprendre le langage php et la gestion de base sql (ce qui n'est pas simple)
J'avoue que je bloque sur deux trois trucs je m'explique:
J'ai une page qui m'affiche des données de mysql (14 colonnes dont la 1ère l'id incrémenté dans sql) jusque la tout va bien la moitié des colonnes sont a compléter par un utilisateur.
Pour cela il clique sur l'id à modifier et cela l'emmène sur une feuille où (et c'est la que ca se complique pour moi)
il voit un formulaire avec les données des 7. 1ère colonnes sans pouvoir les modifier.
Mais, il faut qu'il puisse modifier le reste des colonnes, donc ajouter des données dans mysql selon l'id choisit avec un bouton valider.
Un petiit plus pour les amateurs je veux faire aussi un bouton qui permet d'archiver une ligne l'utilisateur devra rentrer l'id et cela supprimera cette ligne de la table pour la mettre dans une autre qui se nomme archive.
Je suis assez novice dans ce langage si une ame charitable pouvait m'éclaircir merci d'avnce.
Voici le code:
1ère page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
[ Lien ]">
<html xmlns="
[ Lien ]" xml:lang="fr" >
<head>
<title>Suivi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<link href="style.css" rel="stylesheet" type="text/css">
<img style="width: 1040px; height: 120px" src="ogeb.gif" >
<?php
echo '<div style="color:blue; text-align:center;"></font><br /> ';
$date = date("d-m-Y");
$heure = date("H:i");
Print("Nous sommes le $date et il est $heure" );
?>
<table style="width:100%">
<tr>
<td style="text-align:left; width:25%">
<ul style="font-family:comic sans ms, sans-serif; font-size:80%; color:blue; background-color:transparent; text-decoration:underline; text-align:left">
<li><a href="
[ Lien ]" title="Accueil">Accueil</a> </li>
<li><a href="
[ Lien ]" title="ogeb_demande">Demande</a></li>
<li><a href="
[ Lien ]" title="ogeb_suivi">Suivi</a> </li>
<li><a href="
[ Lien ]" title="ogeb_archive">Archive</a></li>
</ul>
<td>
<td style="text-align:center">
<h1>Bienvenue sur l'OGEB SMEC</h1>
<h2>
Outil de Gestion d'Expressions des Besoins
</h2>
<td>
<td style="width:25%">
<FORM name="demande" method="post" action="archive.php">
<p>
<INPUT Value="Archiver une demande" Type="SUBMIT" >
</p>
</FORM>
<td>
<tr>
</table>
<p>
<label for="Filtre">Filtre</label><br />
<select name="Filtre" id="Filtre" tabindex="40">
<option value="ALL" selected>Toutes</option>
<option value="id">Numéro</option>
<option value="date">Date</option>
<option value="uet">UET</option>
<option value="nom">Nom</option>
<option value="destinataire">Destinataire</option>
</select>
</p>
<link href="style.css" rel="stylesheet" type="text/css">
<?php
// information pour la connection à le DB
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'ogeb';
// connection à la DB
$link = mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error() );
mysql_select_db($db) or die ('Erreur :'.mysql_error());
// requête SQL qui compte le nombre total d'enregistrements dans la table et qui
//récupère tous les enregistrements
$select = 'SELECT id,date,uet,nom,delai,destinataire,libelle,pilote,reponse,complementaire,fournisseur,avancement,temps,fin FROM suivi_ogeb';
$result = mysql_query($select,$link) or die ('Erreur : '.mysql_error() );
$total = mysql_num_rows($result);
// si on a récupéré un résultat on l'affiche.
if($total) {
// début du tableau
echo '<table style="width: 2500px" bgcolor="#FFFFFF">'."\n";
// première ligne on affiche les titres prénom et surnom dans 2 colonnes
echo '<tr>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc; border-left: 4px groove #f6f9fc"><b><p style="color:blue">Numéro</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Date</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">UET</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Nom</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Délai</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Destinataire</p></b></td>';
echo '<td style="background-color: #3be7bf; width:15%; border-right: 4px groove red; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc""><b><p style="color:blue">Libellé</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Pilote</p></b></td>';
echo '<td style="background-color: #3be7bf; width:15%; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Réponse</p></b></td>';
echo '<td style="background-color: #3be7bf; width:15%; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Informations complementaires</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Informations fournisseurs</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue"></u>Avancement</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc"><b><p style="color:blue">Temps passé</p></b></td>';
echo '<td nowrap style="background-color: #3be7bf; border-bottom: 4px groove #f6f9fc; border-top: 4px groove #f6f9fc; border-right: 4px groove #f6f9fc"><b><p style="color:blue">Date de fin</p></b></td>';
echo '</tr>'."\n";
// lecture et affichage des résultats sur 2 colonnes, 1 résultat par ligne.
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; border-left: 4px groove #f6f9fc"><a href=suivi.php?id=$id>'.$row['id'].'</a></td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['date'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['uet'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['nom'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['delai'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['destinataire'].'</td>';
echo '<td style="color:black; width:15%; border-right: 4px groove red; border-bottom: 4px groove #f6f9fc">'.$row['libelle'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['pilote'].'</td>';
echo '<td style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc; width:15%">'.$row['reponse'].'</td>';
echo '<td style="color:black; width:15%; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['complementaire'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['fournisseur'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['avancement'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['temps'].'</td>';
echo '<td nowrap style="color:black; border-right: 4px groove #f6f9fc; border-bottom: 4px groove #f6f9fc">'.$row['fin'].'</td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
// fin du tableau.
}
else echo 'Pas d\'enregistrements dans cette table...';
// on libère le résultat
mysql_free_result($result);
?>
</script>
</body>
</html>
2ème page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
[ Lien ]">
<html xmlns="
[ Lien ]" xml:lang="fr" >
<head>
<title>Suivi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<link href="style.css" rel="stylesheet" type="text/css">
<img style="width: 1040px; height: 120px" src="ogeb.gif" >
<?php
$cnx = mysql_connect( "localhost", "root") or die (mysql_error());
$db = mysql_select_db( "ogeb" ) or die (mysql_error());
$id = $_GET["id"] ;
$sql = "SELECT * FROM suivi_ogeb
WHERE id= '$id' ";
$requete = mysql_query( $sql, $cnx ) or die (mysql_error());
if( $result = mysql_fetch_object( $requete ) )
?>
<form method='post' action='suivi.php'>
<?php
echo($result->id) ;
echo($result->date) ;
echo($result->uet) ;
echo($result->nom) ;
echo($result->delai) ;
echo($result->destinataire) ;
echo($result->libelle) ;
?>
<input name="pilote" id="pilote" value=<?php"$result->pilote"?>>
<input name="reponse" id="reponse" value=<?php"$result->reponse"?>>
<input value="Envoyer" type="submit">
<input value="Annuler" type="reset">
</form>
</body>
</html>
Donc là où je bloque c'est pour le formulaire de modification.
Bon vous allez trouver sans doute pas mal d'erreur mais ne soyez pas trop dur je découvre le php (que je trouve d'ailleur passionnant) Je prend toutes les remarques à condition qu'elles soient intéressantes bien sur.
Le site sera utilisé sur IE.
Merci d'avnce et bonne journée...
