par
Sebe » 20 janv. 2006, 21:05
Visiblement cela fonctionne car les données sont encodées dans la tables sauf que j'ai un message d'erreur!
L'idée est de faire l'enregistrement (page 3) et de revenir à la page (2) qui permet de lister les affectations avec la variable 'part' mais ...
Voici mon code
<?php require_once('../Connections/kainbuye.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO acrho_changement (acrho_club_id_club, acrho_participant_ID_participant, annee, dossard, acrho_categorie_ID_categorie) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['club'], "int"),
GetSQLValueString($_POST['participant'], "int"),
GetSQLValueString($_POST['annee'], "date"),
GetSQLValueString($_POST['dossard'], "int"),
GetSQLValueString($_POST['categorie'], "int"));
mysql_select_db($database_kainbuye, $kainbuye);
$Result1 = mysql_query($insertSQL, $kainbuye) or die(mysql_error());
$insertGoTo = "affectation.php?part=" . $row_participant['ID_coureur'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_participant = "-1";
if (isset($_GET['part'])) {
$colname_participant = (get_magic_quotes_gpc()) ? $_GET['part'] : addslashes($_GET['part']);
}
mysql_select_db($database_kainbuye, $kainbuye);
$query_participant = sprintf("SELECT ID_coureur, nom, prenom FROM acrho_participant WHERE ID_coureur = %s", $colname_participant);
$participant = mysql_query($query_participant, $kainbuye) or die(mysql_error());
$row_participant = mysql_fetch_assoc($participant);
$totalRows_participant = mysql_num_rows($participant);
mysql_select_db($database_kainbuye, $kainbuye);
$query_club = "SELECT * FROM acrho_club ORDER BY nom_cub ASC";
$club = mysql_query($query_club, $kainbuye) or die(mysql_error());
$row_club = mysql_fetch_assoc($club);
$totalRows_club = mysql_num_rows($club);
mysql_select_db($database_kainbuye, $kainbuye);
$query_categorie = "SELECT id_categorie, nom_categorie, sexe FROM acrho_categorie ORDER BY age_min ASC";
$categorie = mysql_query($query_categorie, $kainbuye) or die(mysql_error());
$row_categorie = mysql_fetch_assoc($categorie);
$totalRows_categorie = mysql_num_rows($categorie);
mysql_select_db($database_kainbuye, $kainbuye);
$query_chang = "SELECT * FROM acrho_changement";
$chang = mysql_query($query_chang, $kainbuye) or die(mysql_error());
$row_chang = mysql_fetch_assoc($chang);
$totalRows_chang = mysql_num_rows($chang);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nouvelle affectation</title>
</head>
<body>
<table width="565" border="0" cellpadding="0" cellspacing="0" class="cosmic18">
<!--DWLayoutTable-->
<tr>
<td width="40" height="23"> </td>
<td width="475"> </td>
<td width="50"> </td>
</tr>
<tr>
<td height="26" colspan="3" valign="top"><div align="center">Ajouter l'affectation à <strong><?php echo $row_participant['prenom']; ?> <?php echo $row_participant['nom']; ?></strong></div></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="35"> </td>
<td valign="top"><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="100%" border="1">
<tr>
<td>Année</td>
<td><label>
<select name="annee" id="annee">
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select>
<input name="participant" type="hidden" id="participant" value="<?php echo $row_participant['ID_coureur']; ?>" />
</label></td>
</tr>
<tr>
<td>Dossard</td>
<td><label>
<input name="dossard" type="text" id="dossard" size="5" maxlength="5" />
</label></td>
</tr>
<tr>
<td>Club</td>
<td><label>
<select name="club" id="club">
<?php
do {
?><option value="<?php echo $row_club['id_club']?>"<?php if (!(strcmp($row_club['id_club'], $row_chang['acrho_club_id_club']))) {echo "selected=\"selected\"";} ?>><?php echo $row_club['nom_cub']?></option>
<?php
} while ($row_club = mysql_fetch_assoc($club));
$rows = mysql_num_rows($club);
if($rows > 0) {
mysql_data_seek($club, 0);
$row_club = mysql_fetch_assoc($club);
}
?>
</select>
</label></td>
</tr>
<tr>
<td>Catégorie</td>
<td><label>
<select name="categorie" id="categorie">
<?php
do {
?><option value="<?php echo $row_categorie['id_categorie']?>"<?php if (!(strcmp($row_categorie['id_categorie'], $row_chang['acrho_categorie_ID_categorie']))) {echo "selected=\"selected\"";} ?>><?php echo $row_categorie['nom_categorie']?></option>
<?php
} while ($row_categorie = mysql_fetch_assoc($categorie));
$rows = mysql_num_rows($categorie);
if($rows > 0) {
mysql_data_seek($categorie, 0);
$row_categorie = mysql_fetch_assoc($categorie);
}
?>
</select>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit" value="Ajouter l'affectation" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</td>
<td> </td>
</tr>
<tr>
<td height="299"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html><?php
mysql_free_result($participant);
mysql_free_result($club);
mysql_free_result($categorie);
mysql_free_result($chang);
?>
Merci
Visiblement cela fonctionne car les données sont encodées dans la tables sauf que j'ai un message d'erreur!
L'idée est de faire l'enregistrement (page 3) et de revenir à la page (2) qui permet de lister les affectations avec la variable 'part' mais ...
[img]http://img506.imageshack.us/img506/6254/affect8or.jpg[/img]
Voici mon code
[php]<?php require_once('../Connections/kainbuye.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO acrho_changement (acrho_club_id_club, acrho_participant_ID_participant, annee, dossard, acrho_categorie_ID_categorie) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['club'], "int"),
GetSQLValueString($_POST['participant'], "int"),
GetSQLValueString($_POST['annee'], "date"),
GetSQLValueString($_POST['dossard'], "int"),
GetSQLValueString($_POST['categorie'], "int"));
mysql_select_db($database_kainbuye, $kainbuye);
$Result1 = mysql_query($insertSQL, $kainbuye) or die(mysql_error());
$insertGoTo = "affectation.php?part=" . $row_participant['ID_coureur'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_participant = "-1";
if (isset($_GET['part'])) {
$colname_participant = (get_magic_quotes_gpc()) ? $_GET['part'] : addslashes($_GET['part']);
}
mysql_select_db($database_kainbuye, $kainbuye);
$query_participant = sprintf("SELECT ID_coureur, nom, prenom FROM acrho_participant WHERE ID_coureur = %s", $colname_participant);
$participant = mysql_query($query_participant, $kainbuye) or die(mysql_error());
$row_participant = mysql_fetch_assoc($participant);
$totalRows_participant = mysql_num_rows($participant);
mysql_select_db($database_kainbuye, $kainbuye);
$query_club = "SELECT * FROM acrho_club ORDER BY nom_cub ASC";
$club = mysql_query($query_club, $kainbuye) or die(mysql_error());
$row_club = mysql_fetch_assoc($club);
$totalRows_club = mysql_num_rows($club);
mysql_select_db($database_kainbuye, $kainbuye);
$query_categorie = "SELECT id_categorie, nom_categorie, sexe FROM acrho_categorie ORDER BY age_min ASC";
$categorie = mysql_query($query_categorie, $kainbuye) or die(mysql_error());
$row_categorie = mysql_fetch_assoc($categorie);
$totalRows_categorie = mysql_num_rows($categorie);
mysql_select_db($database_kainbuye, $kainbuye);
$query_chang = "SELECT * FROM acrho_changement";
$chang = mysql_query($query_chang, $kainbuye) or die(mysql_error());
$row_chang = mysql_fetch_assoc($chang);
$totalRows_chang = mysql_num_rows($chang);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nouvelle affectation</title>
</head>
<body>
<table width="565" border="0" cellpadding="0" cellspacing="0" class="cosmic18">
<!--DWLayoutTable-->
<tr>
<td width="40" height="23"> </td>
<td width="475"> </td>
<td width="50"> </td>
</tr>
<tr>
<td height="26" colspan="3" valign="top"><div align="center">Ajouter l'affectation à <strong><?php echo $row_participant['prenom']; ?> <?php echo $row_participant['nom']; ?></strong></div></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="35"> </td>
<td valign="top"><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="100%" border="1">
<tr>
<td>Année</td>
<td><label>
<select name="annee" id="annee">
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select>
<input name="participant" type="hidden" id="participant" value="<?php echo $row_participant['ID_coureur']; ?>" />
</label></td>
</tr>
<tr>
<td>Dossard</td>
<td><label>
<input name="dossard" type="text" id="dossard" size="5" maxlength="5" />
</label></td>
</tr>
<tr>
<td>Club</td>
<td><label>
<select name="club" id="club">
<?php
do {
?><option value="<?php echo $row_club['id_club']?>"<?php if (!(strcmp($row_club['id_club'], $row_chang['acrho_club_id_club']))) {echo "selected=\"selected\"";} ?>><?php echo $row_club['nom_cub']?></option>
<?php
} while ($row_club = mysql_fetch_assoc($club));
$rows = mysql_num_rows($club);
if($rows > 0) {
mysql_data_seek($club, 0);
$row_club = mysql_fetch_assoc($club);
}
?>
</select>
</label></td>
</tr>
<tr>
<td>Catégorie</td>
<td><label>
<select name="categorie" id="categorie">
<?php
do {
?><option value="<?php echo $row_categorie['id_categorie']?>"<?php if (!(strcmp($row_categorie['id_categorie'], $row_chang['acrho_categorie_ID_categorie']))) {echo "selected=\"selected\"";} ?>><?php echo $row_categorie['nom_categorie']?></option>
<?php
} while ($row_categorie = mysql_fetch_assoc($categorie));
$rows = mysql_num_rows($categorie);
if($rows > 0) {
mysql_data_seek($categorie, 0);
$row_categorie = mysql_fetch_assoc($categorie);
}
?>
</select>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit" value="Ajouter l'affectation" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</td>
<td> </td>
</tr>
<tr>
<td height="299"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html><?php
mysql_free_result($participant);
mysql_free_result($club);
mysql_free_result($categorie);
mysql_free_result($chang);
?>[/php]
Merci