je débute en php, j'ai réalisé un catalogue avec 2 tables , menu et articles.
table articles suivante:

dans mon espace administration , j'ai crée une page pour la modification des éléments de cette table.

voici les codes complets
formulaire:
<form action="<?php echo $editFormAction; ?>" name="form1" id="form1" enctype="multipart/form-data" method="POST">
<table width="55%" border="0" class="td">
<tr>
<td width="34%"><div align="left"></div></td>
<td width="66%"><div align="left">
<label></label>
</div></td>
</tr>
<tr>
<td><div align="left">Titre:</div></td>
<td><div align="left">
<label></label>
<label>
<input name="titre" type="text" id="titre" value="<?php echo $row_Rsmodifclient['titre']; ?>" size="32" />
</label>
</div></td>
</tr>
<tr>
<td><div align="left">Description:</div></td>
<td><label>
<div align="left">
<textarea name="description" cols="60" rows="3" id="description"><?php echo $row_Rsmodifclient['description']; ?></textarea>
</div>
</label></td>
</tr>
<tr>
<td><div align="left">prix:</div></td>
<td><label>
<div align="left">
<input name="prix" type="text" id="prix" value="<?php echo $row_Rsmodifclient['prix']; ?>" size="20" />
€</div>
</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="left">Sous menu:</div></td>
<td><label>
<div align="left">
<select name="ref_menu" id="ref_menu" >
<?php
do {
?>
<option value="<?php echo $row_rsSelectTheme['id_menu']?>"<?php if (!(strcmp($row_rsSelectTheme['id_menu'], $row_Rsmodifclient['ref_menu']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsSelectTheme['item_menu']?></option>
<?php
} while ($row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme));
$rows = mysql_num_rows($rsSelectTheme);
if($rows > 0) {
mysql_data_seek($rsSelectTheme, 0);
$row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme);
}
?>
</select>
</div>
</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="left">Image:</div></td>
<td><div align="left">
<label>
<input name="photo" type="file" id="photo" value="<?php echo $row_Rsmodifclient['photo']; ?>" size="50" />
</label>
</div></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><div align="left">
<input name="id_menu" type="hidden" id="id_menu" value="<?php echo $row_Rsmodifclient['reference']; ?>" />
</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Modifier" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
</form>
la requête de modification:
<?php require_once('../Connections/dream.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE articles SET ref_menu=%s, titre=%s, description=%s, prix=%s, photo=%s WHERE reference=%s",
GetSQLValueString($_POST['ref_menu'], "int"),
GetSQLValueString($_POST['titre'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['prix'], "double"),
GetSQLValueString($_POST['photo'], "text"),
GetSQLValueString($_POST['id_menu'], "int"));
mysql_select_db($database_dream, $dream);
$Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
$updateGoTo = "valider.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Rsmodifclient = "-1";
if (isset($_GET['reference'])) {
$colname_Rsmodifclient = $_GET['reference'];
}
mysql_select_db($database_dream, $dream);
$query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", $colname_Rsmodifclient);
$Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
$row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
$totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient);
mysql_select_db($database_dream, $dream);
$query_rsSelectTheme = "SELECT * FROM menu ORDER BY id_menu ASC";
$rsSelectTheme = mysql_query($query_rsSelectTheme, $dream) or die(mysql_error());
$row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme);
$totalRows_rsSelectTheme = mysql_num_rows($rsSelectTheme);
?> je peux modifier sans erreur tous les éléments de la table sauf l'image. De même si je modifie n'importe quel champ , sans modifier celui de l'image, celle-ci disparaît automatiquement de ma table. Même, en effectuant un 2 ème passage , impossible de rajouter l'mage.
Avez-vous déjà rencontré ce problème et comment le résoudre? Merci