par
Luverger » 24 août 2007, 15:41
Voici le code de ma page d'insert pour une nouvelle documentation :
Code : Tout sélectionner
<?php require_once('../Connections/ConnexionBiblio.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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($_POS["MM_insert"])) && ($_POS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tableproduit (RefProduit, ProduitNumChemise, ProduitNumCD, ProduitMarque, ProduitFournisseur, ProduitType, ProduitDate) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POS['RefProduit'], "int"),
GetSQLValueString($_POS['ProduitNumChemise'], "int"),
GetSQLValueString($_POS['ProduitNumCD'], "int"),
GetSQLValueString($_POS['ProduitMarque'], "int"),
GetSQLValueString($_POS['ProduitFournisseur'], "int"),
GetSQLValueString($_POS['ProduitType'], "text"),
GetSQLValueString($_POS['ProduitDate'], "date"));
mysql_select_db($database_ConnexionBiblio, $ConnexionBiblio);
$Result1 = mysql_query($insertSQL, $ConnexionBiblio) or die(mysql_error());
}
mysql_select_db($database_ConnexionBiblio, $ConnexionBiblio);
$query_rsDocument = "SELECT * FROM tableproduit";
$rsDocument = mysql_query($query_rsDocument, $ConnexionBiblio) or die(mysql_error());
$row_rsDocument = mysql_fetch_assoc($rsDocument);
$totalRows_rsDocument = mysql_num_rows($rsDocument);
mysql_select_db($database_ConnexionBiblio, $ConnexionBiblio);
$query_rsSociete = "SELECT RefSociete, SocieteNom FROM tablesociete ORDER BY SocieteNom ASC";
$rsSociete = mysql_query($query_rsSociete, $ConnexionBiblio) or die(mysql_error());
$row_rsSociete = mysql_fetch_assoc($rsSociete);
$totalRows_rsSociete = mysql_num_rows($rsSociete);
?>
<html><!-- InstanceBegin template="/Templates/PageBiblio.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body bgcolor="#F2F2F2" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="803" height="256" border="0" align="center" cellspacing="0">
<tr align="right" valign="top">
<td height="100" colspan="3" bordercolor="0"><div align="center">
<p align="left"><strong><img src="../Images/logo%20CMF.jpg" width="339" height="100"><img src="../Images/logo%20BIBLIO.jpg" width="461" height="100"></strong></p>
</div> </td>
</tr>
<tr valign="bottom">
<td height="18" colspan="3"><div align="right"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">v
0.95</font></div></td>
</tr>
<tr align="center" valign="middle" background="../Images/Degrade2.jpg">
<td width="230" height="35">
<a href="../index.htm"><font size="2"><font color="#666666" face="Arial, Helvetica, sans-serif"><strong>RECHERCHE</strong></font></font></a> </td>
<td width="335" height="35"><div align="center">
<select name="menuAjout" onChange="MM_jumpMenu('parent',this,0)">
<option selected>-- AJOUT -- </option>
<option value="PageAjoutContact.php">Un contact </option>
<option value="PageAjoutSociete.php">Une société </option>
<option value="PageAjoutDocument.php">Un document </option>
</select>
<div align="center">
</div> </td>
<td width="238" height="35"><div align="center">
<select name="menuListes" onChange="MM_jumpMenu('parent',this,0)">
<option value="../index.php" selected>-- LISTES -- </option>
<option value="../Listes/listeContacts.php">Contacts </option>
<option value="../Listes/listesocietes.php">Sociétés </option>
<option value="../Listes/listeChemises.php">Chemises par type de produit </option>
<option value="../Listes/listeChemisesParMarque.php">Chemises par marque </option>
<option value="../Listes/listeChemisesParNum.php">Chemises par N° </option>
<option value="../Listes/listeCDs.php">Documentation en CD </option>
</select>
</div></td>
</tr>
<tr bgcolor="#F2F2F2">
<td height="58" colspan="3"><div align="center"><font size="6"><font face="Arial, Helvetica, sans-serif"></font></font>
<p><font size="6"><!-- InstanceBeginEditable name="EditRegion1" --><u><font face="Arial, Helvetica, sans-serif">AJOUT
de documentation</font></u><!-- InstanceEndEditable --></font></p>
</div>
<div align="center"></div>
<div align="center"><font color="#3366FF" size="2" face="Arial">La Base de données </font><font color="#3366FF" size="2" face="Arial"> compte
<?php
require_once('../Connections/ConnexionBiblio.php');
//On insère la requete dans une chaine
$requete = "SELECT COUNT(ProduitType) FROM tableproduit";
//On exécute la requete que l'on stocke dans un resultat de base de données
$result = mysql_query($requete);
//On récupère la ligne suivante (la premiere puisque c'est la premiere fois) dans un tableau
$row = mysql_fetch_array($result);
//On affiche la premiere ligne du tableau
echo $row[0];
/* NB : count(*) compte déjà; le nombre de ligne, si ensuite tu fais un mysql_num_rows il va compter le nombre d'enregistrement de ta requete soit un seul puisque l'enregistrement contient déjà; le compte que tu désires */
?>
résultats</font><font color="#3366FF"><?php
/**
* Fonction simple identique à celle en PHP 5 qui va suivre
*/
// function microtime_float()
// {
// list($usec, $sec) = explode(" ", microtime());
// return ((float)$usec + (float)$sec);
// }
//
// $time_start = microtime_float();
//
// Attend pendant un moment
// usleep(100);
//
// $time_end = microtime_float();
// $time = $time_end - $time_start;
//
// echo "en $time secondes\n";
// ?>
</font> </div>
<table width="97%" height="43%" align="center">
<tr>
<td width="80%" height="34"><div align="center"><!-- InstanceBeginEditable name="EditRegion2" -->
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<p> </p>
<table align="center">
<tr valign="baseline">
<td width="123" height="35" align="right" nowrap><font size="2" face="Arial, Helvetica, sans-serif">N°
de chemise</font></td>
<td width="517"><p>
<input type="text" name="ProduitNumChemise" value="" size="10">
<font color="#FF0000">*</font>
<font size="2" face="Arial, Helvetica, sans-serif">(Méca
: de 1000 à 4999, Normes : 5000 à 5999,
Autom de 6000 à 6999)</font></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">N°
de CD</font></td>
<td><input type="text" name="ProduitNumCD" value="" size="7">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">Marque</font></td>
<td>
<font color="#FF0000">
<select name="ProduitMarque">
<?php
do {
?>
<option value="<?php echo $row_rsSociete['RefSociete']?>"><?php echo $row_rsSociete['SocieteNom']?></option>
<?php
} while ($row_rsSociete = mysql_fetch_assoc($rsSociete));
$rows = mysql_num_rows($rsSociete);
if($rows > 0) {
mysql_data_seek($rsSociete, 0);
$row_rsSociete = mysql_fetch_assoc($rsSociete);
}
?>
</select>
*</font> </td>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">Fournisseur</font></td>
<td>
<select name="ProduitFournisseur">
<?php
do {
?>
<option value="<?php echo $row_rsSociete['RefSociete']?>"><?php echo $row_rsSociete['SocieteNom']?></option>
<?php
} while ($row_rsSociete = mysql_fetch_assoc($rsSociete));
$rows = mysql_num_rows($rsSociete);
if($rows > 0) {
mysql_data_seek($rsSociete, 0);
$row_rsSociete = mysql_fetch_assoc($rsSociete);
}
?>
</select>
</td>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">TYPE
DE PRODUIT</font></td>
<td><input name="ProduitType" type="text" value="" size="75" maxlength="70">
<font color="#FF0000"> * </font>(M)</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">Date</font></td>
<td><input name="ProduitDate" type="text" value="" size="12" maxlength="10">
<font size="2" face="Arial, Helvetica, sans-serif">(Attention
au format : aaaa-mm-dd !! )</font>
</td>
</tr>
<tr valign="bottom">
<td height="47" colspan="2" align="right" nowrap><div align="center"></div> <div align="center">
<input name="Ajouter" type="submit" id="Ajouter" value="Ajouter">
</div></td>
</tr>
</table>
<input type="hidden" name="RefProduit" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>
<div align="left">
<p><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">*
champs obligatoires</font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif">(M) écrire
en majuscules</font></p>
</div>
<!-- InstanceEndEditable --></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<p> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rsDocument);
mysql_free_result($rsSociete);
?>
Si ça vous permet de m'aider ...
Merci encore
Voici le code de ma page d'insert pour une nouvelle documentation :
[code]
<?php require_once('../Connections/ConnexionBiblio.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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($_POS["MM_insert"])) && ($_POS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tableproduit (RefProduit, ProduitNumChemise, ProduitNumCD, ProduitMarque, ProduitFournisseur, ProduitType, ProduitDate) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POS['RefProduit'], "int"),
GetSQLValueString($_POS['ProduitNumChemise'], "int"),
GetSQLValueString($_POS['ProduitNumCD'], "int"),
GetSQLValueString($_POS['ProduitMarque'], "int"),
GetSQLValueString($_POS['ProduitFournisseur'], "int"),
GetSQLValueString($_POS['ProduitType'], "text"),
GetSQLValueString($_POS['ProduitDate'], "date"));
mysql_select_db($database_ConnexionBiblio, $ConnexionBiblio);
$Result1 = mysql_query($insertSQL, $ConnexionBiblio) or die(mysql_error());
}
mysql_select_db($database_ConnexionBiblio, $ConnexionBiblio);
$query_rsDocument = "SELECT * FROM tableproduit";
$rsDocument = mysql_query($query_rsDocument, $ConnexionBiblio) or die(mysql_error());
$row_rsDocument = mysql_fetch_assoc($rsDocument);
$totalRows_rsDocument = mysql_num_rows($rsDocument);
mysql_select_db($database_ConnexionBiblio, $ConnexionBiblio);
$query_rsSociete = "SELECT RefSociete, SocieteNom FROM tablesociete ORDER BY SocieteNom ASC";
$rsSociete = mysql_query($query_rsSociete, $ConnexionBiblio) or die(mysql_error());
$row_rsSociete = mysql_fetch_assoc($rsSociete);
$totalRows_rsSociete = mysql_num_rows($rsSociete);
?>
<html><!-- InstanceBegin template="/Templates/PageBiblio.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body bgcolor="#F2F2F2" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="803" height="256" border="0" align="center" cellspacing="0">
<tr align="right" valign="top">
<td height="100" colspan="3" bordercolor="0"><div align="center">
<p align="left"><strong><img src="../Images/logo%20CMF.jpg" width="339" height="100"><img src="../Images/logo%20BIBLIO.jpg" width="461" height="100"></strong></p>
</div> </td>
</tr>
<tr valign="bottom">
<td height="18" colspan="3"><div align="right"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">v
0.95</font></div></td>
</tr>
<tr align="center" valign="middle" background="../Images/Degrade2.jpg">
<td width="230" height="35">
<a href="../index.htm"><font size="2"><font color="#666666" face="Arial, Helvetica, sans-serif"><strong>RECHERCHE</strong></font></font></a> </td>
<td width="335" height="35"><div align="center">
<select name="menuAjout" onChange="MM_jumpMenu('parent',this,0)">
<option selected>-- AJOUT -- </option>
<option value="PageAjoutContact.php">Un contact </option>
<option value="PageAjoutSociete.php">Une société </option>
<option value="PageAjoutDocument.php">Un document </option>
</select>
<div align="center">
</div> </td>
<td width="238" height="35"><div align="center">
<select name="menuListes" onChange="MM_jumpMenu('parent',this,0)">
<option value="../index.php" selected>-- LISTES -- </option>
<option value="../Listes/listeContacts.php">Contacts </option>
<option value="../Listes/listesocietes.php">Sociétés </option>
<option value="../Listes/listeChemises.php">Chemises par type de produit </option>
<option value="../Listes/listeChemisesParMarque.php">Chemises par marque </option>
<option value="../Listes/listeChemisesParNum.php">Chemises par N° </option>
<option value="../Listes/listeCDs.php">Documentation en CD </option>
</select>
</div></td>
</tr>
<tr bgcolor="#F2F2F2">
<td height="58" colspan="3"><div align="center"><font size="6"><font face="Arial, Helvetica, sans-serif"></font></font>
<p><font size="6"><!-- InstanceBeginEditable name="EditRegion1" --><u><font face="Arial, Helvetica, sans-serif">AJOUT
de documentation</font></u><!-- InstanceEndEditable --></font></p>
</div>
<div align="center"></div>
<div align="center"><font color="#3366FF" size="2" face="Arial">La Base de données </font><font color="#3366FF" size="2" face="Arial"> compte
<?php
require_once('../Connections/ConnexionBiblio.php');
//On insère la requete dans une chaine
$requete = "SELECT COUNT(ProduitType) FROM tableproduit";
//On exécute la requete que l'on stocke dans un resultat de base de données
$result = mysql_query($requete);
//On récupère la ligne suivante (la premiere puisque c'est la premiere fois) dans un tableau
$row = mysql_fetch_array($result);
//On affiche la premiere ligne du tableau
echo $row[0];
/* NB : count(*) compte déjà; le nombre de ligne, si ensuite tu fais un mysql_num_rows il va compter le nombre d'enregistrement de ta requete soit un seul puisque l'enregistrement contient déjà; le compte que tu désires */
?>
résultats</font><font color="#3366FF"><?php
/**
* Fonction simple identique à celle en PHP 5 qui va suivre
*/
// function microtime_float()
// {
// list($usec, $sec) = explode(" ", microtime());
// return ((float)$usec + (float)$sec);
// }
//
// $time_start = microtime_float();
//
// Attend pendant un moment
// usleep(100);
//
// $time_end = microtime_float();
// $time = $time_end - $time_start;
//
// echo "en $time secondes\n";
// ?>
</font> </div>
<table width="97%" height="43%" align="center">
<tr>
<td width="80%" height="34"><div align="center"><!-- InstanceBeginEditable name="EditRegion2" -->
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<p> </p>
<table align="center">
<tr valign="baseline">
<td width="123" height="35" align="right" nowrap><font size="2" face="Arial, Helvetica, sans-serif">N°
de chemise</font></td>
<td width="517"><p>
<input type="text" name="ProduitNumChemise" value="" size="10">
<font color="#FF0000">*</font>
<font size="2" face="Arial, Helvetica, sans-serif">(Méca
: de 1000 à 4999, Normes : 5000 à 5999,
Autom de 6000 à 6999)</font></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">N°
de CD</font></td>
<td><input type="text" name="ProduitNumCD" value="" size="7">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">Marque</font></td>
<td>
<font color="#FF0000">
<select name="ProduitMarque">
<?php
do {
?>
<option value="<?php echo $row_rsSociete['RefSociete']?>"><?php echo $row_rsSociete['SocieteNom']?></option>
<?php
} while ($row_rsSociete = mysql_fetch_assoc($rsSociete));
$rows = mysql_num_rows($rsSociete);
if($rows > 0) {
mysql_data_seek($rsSociete, 0);
$row_rsSociete = mysql_fetch_assoc($rsSociete);
}
?>
</select>
*</font> </td>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">Fournisseur</font></td>
<td>
<select name="ProduitFournisseur">
<?php
do {
?>
<option value="<?php echo $row_rsSociete['RefSociete']?>"><?php echo $row_rsSociete['SocieteNom']?></option>
<?php
} while ($row_rsSociete = mysql_fetch_assoc($rsSociete));
$rows = mysql_num_rows($rsSociete);
if($rows > 0) {
mysql_data_seek($rsSociete, 0);
$row_rsSociete = mysql_fetch_assoc($rsSociete);
}
?>
</select>
</td>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">TYPE
DE PRODUIT</font></td>
<td><input name="ProduitType" type="text" value="" size="75" maxlength="70">
<font color="#FF0000"> * </font>(M)</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="2" face="Arial, Helvetica, sans-serif">Date</font></td>
<td><input name="ProduitDate" type="text" value="" size="12" maxlength="10">
<font size="2" face="Arial, Helvetica, sans-serif">(Attention
au format : aaaa-mm-dd !! )</font>
</td>
</tr>
<tr valign="bottom">
<td height="47" colspan="2" align="right" nowrap><div align="center"></div> <div align="center">
<input name="Ajouter" type="submit" id="Ajouter" value="Ajouter">
</div></td>
</tr>
</table>
<input type="hidden" name="RefProduit" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>
<div align="left">
<p><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">*
champs obligatoires</font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif">(M) écrire
en majuscules</font></p>
</div>
<!-- InstanceEndEditable --></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<p> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rsDocument);
mysql_free_result($rsSociete);
?>
[/code]
Si ça vous permet de m'aider ...
Merci encore