Bonjour,
Je rencontre quelques difficultés à lié 2 formulaires. Je m'explique, à partir d'une liste déroulante j'aimerais que le formulaire s'adapte avec le choix que nous avons choisi dans la liste déroulante.
Pourriez-vous m'aider à résoudre mon problème svp? si vous avez trouvé mon erreur, pourriez-vous me la communiquer rapidement?
Merci d'avance pour votre aide
Voici le code:
<?php require_once('../Connections/conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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 contenu SET titre_1=%s, titre_2=%s, keywords=%s, descriptionn=%s, contenu=%s, id_lieu=%s, $choix=%s WHERE id_contenu=%s",
GetSQLValueString($_POST['titre_1'], "text"),
GetSQLValueString($_POST['titre_2'], "text"),
GetSQLValueString($_POST['keywords'], "text"),
GetSQLValueString($_POST['descriptionn'], "text"),
GetSQLValueString($_POST['contenu'], "text"),
GetSQLValueString($_POST['id_lieu'], "int"),
GetSQLValueString($choix, "text"),
GetSQLValueString($_POST['id_contenu'], "int"));
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($updateSQL, $conn) or die(mysql_error());
}
mysql_select_db($database_conn, $conn);
$query_Recordset2 = "SELECT * FROM 'banniere' WHERE 'id_lieu' =2 ";
$Recordset2 = mysql_query($query_Recordset2, $conn) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT * FROM 'contenu' WHERE 'id_lieu' =2 AND 'nom_menu' LIKE '$choix'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!doctype html>
<html><!-- InstanceBegin template="/Templates/neuch_admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="ISO-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Modifier contenu Neuchâtel</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="../neuch_admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
background-color: #999;
}
</style>
<script type="text/javascript" src="easyslider1.7/js/jquery.js"></script>
<script type="text/javascript" src="easyslider1.7/js/easySlider1.7.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#slider").easySlider({
auto: true,
continuous: true
});
});
</script>
<link href="easyslider1.7/css/screen.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="conteneur" >
<div id="conteneur_gauche">
<div id="logo"></div>
<div id="admin"><a href="index.php"></a></div>
<div id="gest_bann"><a href="gest_bann.php"></a></div>
<div id="gest_galerie"><a href="file:///Macintosh%20HD/Applications/MAMP/htdocs/admin/gest_galerie.php"></a></div>
<div id="zone_gauche"></div>
</div>
<div id="conteneur_droite">
<div id="conteneur_bouton">
<div id="bt_fondation"><a href="../fondation/index.php"></a></div>
<div id="bt_action"><a href="../action/index.php"></a></div>
<div id="bt_neuch"></div>
<div id="bt_tchaux"><a href="../tchaux/index.php"></a></div>
</div>
<div id="banniere">
<div id="content">
<div id="slider">
<ul>
<?php do { ?>
<li><img src="file:///Macintosh%20HD/Applications/MAMP/htdocs/foyerhandicap/photos_bann/<?php echo $row_Recordset2['photo']; ?>"/></li>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
</ul>
</div>
</div>
</div>
<div id="titre">
<div align="left"><!-- InstanceBeginEditable name="titre" -->Comment modifier le contenu de son site internet ?
<!-- InstanceEndEditable --></div>
</div>
<div id="corps1">
<div align="left"><!-- InstanceBeginEditable name="corps" -->
<?php
//isset renvoie TRUE si la variable var est définie, FALSE, sinon.
if(isset($_POST['choix']))
$choix=$_POST['choix'];
else $choix="";
?>
<div align="left">
<table align="center">
<tr valign="baseline">
<td>Choisissez un menu parmi cette liste déroulante : </td>
<td>
<form action="" method="post" name="modif">
<select name="choix" onchange="submit()">
<option value="" <?php if ($choix==!(strcmp("", $row_Recordset1['id_lieu']))) {echo "selected=\"selected\"";} ?>>Votre choix</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['nom_menu']?>"<?php if ($choix==!(strcmp($row_Recordset1['nom_menu'], $row_Recordset1['id_lieu']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['nom_menu']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
</form>
</td>
</tr>
</table>
</div>
<?php
if(!empty($choix))
?>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Titre_1:</td>
<td><input type="text" name="titre_1" value="<?php echo htmlentities($row_Recordset1['titre_1'], ENT_COMPAT, 'ISO-8859-1'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Titre_2:</td>
<td><input type="text" name="titre_2" value="<?php echo htmlentities($row_Recordset1['titre_2'], ENT_COMPAT, 'ISO-8859-1'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Keywords:</td>
<td><textarea name="keywords" cols="50" rows="5"><?php echo htmlentities($row_Recordset1['keywords'], ENT_COMPAT, 'ISO-8859-1'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Descriptionn:</td>
<td><textarea name="descriptionn" cols="50" rows="5"><?php echo htmlentities($row_Recordset1['descriptionn'], ENT_COMPAT, 'ISO-8859-1'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Contenu:</td>
<td><textarea name="contenu" cols="50" rows="5"><?php echo htmlentities($row_Recordset1['contenu'], ENT_COMPAT, 'ISO-8859-1'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nom_menu:</td>
<td><input type="text" name="nom_menu" value= "<?php echo $choix; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Mettre à jour l'enregistrement"></td>
</tr>
</table>
<input type="hidden" name="id_contenu" value="<?php echo $row_Recordset1['id_contenu']; ?>">
<input type="hidden" name="id_lieu" value="<?php echo htmlentities($row_Recordset1['id_lieu'], ENT_COMPAT, 'ISO-8859-1'); ?>">
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="id_contenu" value="<?php echo $row_Recordset1['id_contenu']; ?>">
</form>
<p> </p>
<!-- InstanceEndEditable --></div>
</div>
</div>
<div id="pied"></div>
</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($Recordset2);
mysql_free_result($Recordset1);
?>
Afficher la suite
2 mai 2013 à 21:04