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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| <?php
/**
*
*
* @version $Id$
* @copyright 2008
*/
// recupération des data
$sn = $_POST['sn'];
$table = $_POST['listeproduit'];
//selection de la table
// on se connecte à MySQL
$db = mysql_connect('localhost', 'login', 'pass');
// on sélectionne la base
mysql_select_db('base',$db);
//récupération des nom de colonnes
$fields=mysql_list_fields("base",$table);//récupère tout les champs d'un table
$columns=mysql_num_fields($fields);// récupère le nombre de champs d'un table
for($i=0;$i<$columns;$i++)
{
$col[$i] = mysql_field_name($fields,$i);
}
$sql = "SELECT * FROM `".$table."` WHERE Serial_Number = '".$sn."'";
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
?>
<FORM Method="POST" Action="modifdata.php">
<table >
<?php
while($data = mysql_fetch_assoc($req))
{
// on affiche les informations de l'enregistrement en cours
for ($i=1; $i<$columns-2; ++$i)
{
?>
<TR>
<th align=left><?php echo $col[$i]; ?> </th>
<th> : </th>
<th align=left><?php echo $data[$col[$i]]; ?></th>
<th><?php if ($i>6)
{
?>
<input type=text name=val<?php echo $i ; ?> >
</th>
<?php
}
?>
</TR>
<?php
}
}
?>
</table>
<input type=hidden name=col value=<?php echo $columns ; ?>>
<input type=hidden name=table value=<?php echo $table ; ?>>
<INPUT type=submit value=Envoyer>
</form>
<?php
mysql_close();
?> |
Partager