Merci pour votre réponse,
Pour l'instant, j'arrive à faire ce type de tableau. je joins les deux fichiers. Mon problème est actuellement de deux ordre, d'une part, lorsque je modifie des données, les modifications ne sont pas transmises dans la base de données Articles et je n'arrive pas à afficher les données modifiées dans ce même tableau après validation. Dans un second cas est d'appliquer des filtres sur les colonnes afin d'en réaliser un filtrage des données affichées à modifier.
Au final de cette mise en place, c'est de permettre des modifications groupées des PVHT par exemple ou du nom du fournisseur.
Merci de votre aide, je reste joignable par email
[email protected].
Amicalement,
Germano P.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
index3.php
<html>
<head>
<title>Tableau de modification des tarifs</title>
</head>
<body>
<link rel="STYLESHEET" type="text/css" media="all" href="style.css"/>
<div id="global">
<div id="header">
<?php
//On créé une fonction de connection à la base
function connecttest_base(){
$base = mysql_connect ('mysql5-14.perso', 'loisirscogp', 'ydx3cpp');
mysql_select_db ('loisirscogp', $base) ;
//$base = mysql_connect ('localhost', 'admin', 'admin');
//mysql_select_db ('admin', $base) ;
}
?>
</div>
<!-- Menu fixe gauche (édition des règles de gestion) ##WIP## -->
<div id="gauche">
<h1></h1>
<p class="menu">TABLEAU RECAPITULATIF DES ARTICLES</p>
<form name="update" method="post" action="form.php">
<p class="menu"><input type="submit" name="modifier" value="Modifier"/></p>
</form>
<!-- On créé un formulaire permettant d'éditer la table-->
</div>
<!-- Fin Menu fixe gauche -->
<!-- Page_Principale -->
<div id="page_principale">
<?php
//On se connecte
connecttest_base();
//On selectionne la table
$sql = 'SELECT * FROM articles' AND 'SELECT * FROM tvas' AND 'SELECT * FROM articles_stocks_alertes' AND 'SELECT * FROM annu_constructeur' ;
// $sql = 'SELECT ref_interne, lib_article, ref_oem, paa_ht, prix_public_ht, seuil_alerte, ref_constructeur FROM articles, tvas, articles_stocks_alertes, annu_constructeur';
$req = mysql_query($sql) or die('Erreur SQL !
'.$sql.'
'.mysql_error());
//On affiche les champs et paramètres de la table sous forme de tableau
echo '<table border=1 cellpadding=5><tr bgcolor=#DDDDDD>';
echo '<td width=15><center><strong>Ref article</strong></center></td>';
echo '<td width=150><center><strong>Description</strong></center></td>';
echo '<td width=15><center><strong>Ref Fourn</strong></center></td>';
echo '<td width=15><center><strong>PAHT</strong></center></td>';
echo '<td width=15><center><strong>PVHT</strong></center></td>';
echo '<td width=15><center><strong>TVA</strong></center></td>';
echo '<td width=15><center><strong>PVTTC</strong></center></td>';
echo '<td width=10><center><strong>Colisage</strong></center></td>';
echo '<td width=10><center><strong>Stock mini</strong></center></td>';
echo '<td width=25><center><strong>Nom Fournisseur</strong></center></td>';
$i=0; //on initialise l'index
while ($data = mysql_fetch_array($req)) {
echo '<tr><td align=center>'.$data['ref_interne'].'</td>';
echo '<td align=right>'.$data['lib_article'].'</td>';
echo '<td align=right>'.$data['ref_oem'].'</td>';
echo '<td align=right>'.$data['paa_ht'].'</td>';
echo '<td align=right>'.$data['prix_public_ht'].'</td>';
echo '<td align=right>'.$data['id_tva'].'</td>';
echo '<td align=right>'.$data[' '].'</td>';
echo '<td align=right>'.$data[' '].'</td>';
echo '<td align=right>'.$data['seuil_alerte'].'</td>';
echo '<td align=right>'.$data['ref_constructeur'].'</td>';
$i++;// on incrémente l'index
}
echo '</table>';
//On libère la mémoire mobilisée pour cette requête dans sql
//$data de PHP lui est toujours accessible !
mysql_free_result ($req);
//On ferme sql
mysql_close ();
?>
</div>
<!-- Fin Page_Principale -->
</div>
</body>
</html>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Voici aussi le fichier form.php
<html>
<head>
<title>Tableau de modification des tarifs</title>
</head>
<body>
<link rel="STYLESHEET" type="text/css" media="all" href="style.css"/>
<div id="global">
<div id="header">
<?php
//On créé une fonction de connection à la base
function connecttest_base(){
$base = mysql_connect ('mysql5-14.perso', 'loisirscogp', 'ydx3cpp');
mysql_select_db ('loisirscogp', $base) ;
//$base = mysql_connect ('localhost', 'admin', 'admin');
//mysql_select_db ('admin', $base) ;
}
?>
</div>
<!-- Menu fixe gauche (édition des règles de gestion) ##WIP## -->
<div id="gauche">
<h1></h1>
<p class="menu">Modification tarifs</p>
<!-- On créé un formulaire permettant d'éditer la table-->
<form name="update" method="post" action="form.php?form">
<p class="menu"><input type="submit" name="valider" value="Valider" /></p>
</div>
<!-- Fin Menu fixe gauche -->
<!-- Page_Principale -->
<div id="page_principale">
<?php
//On se connecte
connecttest_base();
//On selectionne la table
$sql = 'SELECT * FROM articles' AND 'SELECT * FROM tvas' AND 'SELECT * FROM articles_stocks_alertes' AND 'SELECT * FROM annu_constructeur' ;
// $sql = 'SELECT ref_interne, lib_article, ref_oem, paa_ht, prix_public_ht, seuil_alerte, ref_constructeur FROM articles, tvas, articles_stocks_alertes, annu_constructeur';
//$sql = 'SELECT ref_interne, lib_article, ref_oem, paa_ht, prix_public_ht, seuil_alerte, ref_constructeur FROM articles, tvas, articles_stocks_alertes, annu_constructeur';
$req = mysql_query($sql) or die('Erreur SQL !
'.$sql.'
'.mysql_error());
//On affiche les champs et paramètres de la table sous forme de tableau
echo '<table border=1 cellpadding=5><tr bgcolor=#DDDDDD>';
echo '<td width=15><center><strong>Ref article</strong></center></td>';
echo '<td width=150><center><strong>Description</strong></center></td>';
echo '<td width=15><center><strong>Ref Fourn</strong></center></td>';
echo '<td width=15><center><strong>PAHT</strong></center></td>';
echo '<td width=15><center><strong>PVHT</strong></center></td>';
echo '<td width=15><center><strong>TVA</strong></center></td>';
echo '<td width=15><center><strong>PVTTC</strong></center></td>';
echo '<td width=10><center><strong>Colisage</strong></center></td>';
echo '<td width=10><center><strong>Stock mini</strong></center></td>';
echo '<td width=25><center><strong>Nom Fournisseur</strong></center></td>';
$i=1; // ajout
while ($data = mysql_fetch_array($req))
{
$oldlib_article=$data['lib_article'];
$newlib_article=$data['lib_article'];
$oldref_oem=$data['ref_oem'];
$newref_oem=$data['ref_oem'];
$oldpaa_ht=$data['paa_ht'];
$newpaa_ht=$data['paa_ht'];
$oldprix_public_ht=$data['prix_public_ht'];
$newprix_public_ht=$data['prix_public_ht'];
$oldseuil_alerte=$data['seuil_alerte'];
$newseuil_alerte=$data['seuil_alerte'];
$oldref_constructeur=$data['ref_constructeur'];
$newref_constructeur=$data['ref_constructeur'];
echo '<tr><td align=center>'.$data['ref_interne'].'</td>';
echo '<td align=right><input type="text" name="Description'.$i.'" value="'.$data['lib_article'].'"/>';
echo '<td align=right><input type="text" name="Ref Fourn'.$i.'" value="'.$data['ref_oem'].'"/>';
echo '<td align=right><input type="text" name="PAHT'.$i.'" value="'.$data['paa_ht'].'"/>';
echo '<td align=right><input type="text" name="PVHT'.$i.'" value="'.$data['prix_public_ht'].'"/>';
echo '<td align=right><input type="text" name="TVA'.$i.'" value="'.$data['id_tva'].'"/>';
echo '<td align=right><input type="text" name="PVTTC'.$i.'" value="'.$data[' '].'"/>';
echo '<td align=right><input type="text" name="Colisage'.$i.'" value="'.$data[' '].'"/>';
echo '<td align=right><input type="text" name="Stock Mini'.$i.'" value="'.$data['seuil_alerte'].'"/>';
echo '<td align=right><input type="text" name="Nom Fourn'.$i.'" value="'.$data['ref_constructeur'].'"/>';
echo '<input type="hidden" name="ref_interne'.$i.'" value="'.$data['ref_interne'].'"/>';
echo '<input type="hidden" name="lib_article'.$i.'" value="'.$data['lib_article'].'"/></td></tr>';
echo '<input type="hidden" name="ref_oem'.$i.'" value="'.$data['ref_oem'].'"/>';
echo '<input type="hidden" name="paa_ht'.$i.'" value="'.$data['paa_ht'].'"/></td></tr>';
echo '<input type="hidden" name="prix_public_ht'.$i.'" value="'.$data['prix_public_ht'].'"/>';
echo '<input type="hidden" name="id_tva'.$i.'" value="'.$data['id_tva'].'"/></td></tr>';
echo '<input type="hidden" name=" '.$i.'" value="'.$data[' '].'"/>';
echo '<input type="hidden" name=" '.$i.'" value="'.$data[' '].'"/></td></tr>';
echo '<input type="hidden" name="seuil_alerte'.$i.'" value="'.$data['seuil_alerte'].'"/>';
echo '<input type="hidden" name="ref_constructeur'.$i.'" value="'.$data['ref_constructeur'].'"/></td></tr>';
$i++; // ajout
}
echo '</table>';
echo '</form>';
$max_ID=$i-1;
//A la validation
if(isset($_POST['valider']))
{
for ($i=1;$i<$max_ID;$i++)
{
if ($_POST['N_ref_article_'.$i]!=$_POST['O_ref_article_'.$i])
{
$ref_article=$_POST['N_ref_article_'.$i];
$req = "UPDATE articles SET aricles='$ref_article' WHERE ref_interne='$i'";
mysql_query($req) or die ('Erreur sur : '.$req.'<br/>'.mysql_error());
}
}
header('Refresh: 0; url=index3.php');
}
//On ferme sql
mysql_close ();
?>
</div>
<!-- Fin Page_Principale -->
</div>
</body>
</html>