par
darkvad » 11 mars 2008, 14:50
Bonjour,
je fait un petit site avec une liste de ventes. Mon problème c est l'affichage et la saisie des dates au format fr.
Code : Tout sélectionner
<?php require_once('../bouton/ventes.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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$SSAdv_colors1 = array("#FFFFCC","#999999");
$SSAdv_k1 = 0;
$SSAdv_m1 = 0;
$SSAdv_change_every1 = 1;
$maxRows_listeventes = 10;
$pageNum_listeventes = 0;
if (isset($_GET['pageNum_listeventes'])) {
$pageNum_listeventes = $_GET['pageNum_listeventes'];
}
$startRow_listeventes = $pageNum_listeventes * $maxRows_listeventes;
mysql_select_db($database_gilles, $gilles);
$query_listeventes = "SELECT * FROM ventes ORDER BY id ASC";
$query_limit_listeventes = sprintf("%s LIMIT %d, %d", $query_listeventes, $startRow_listeventes, $maxRows_listeventes);
$listeventes = mysql_query($query_limit_listeventes, $gilles) or die(mysql_error());
$row_listeventes = mysql_fetch_assoc($listeventes);
if (isset($_GET['totalRows_listeventes'])) {
$totalRows_listeventes = $_GET['totalRows_listeventes'];
} else {
$all_listeventes = mysql_query($query_listeventes);
$totalRows_listeventes = mysql_num_rows($all_listeventes);
}
$totalPages_listeventes = ceil($totalRows_listeventes/$maxRows_listeventes)-1;
$queryString_listeventes = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_listeventes") == false &&
stristr($param, "totalRows_listeventes") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_listeventes = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_listeventes = sprintf("&totalRows_listeventes=%d%s", $totalRows_listeventes, $queryString_listeventes);
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Liste des ventes</title>
<style type="text/css">
<!--
body,td,th {
color: #000066;
}
body {
background-color: #FF9933;
}
-->
</style>
<script src="../bouton/AC_RunActiveContent.js" type="text/javascript"></script>
<script id="PLVIMScript" language="JavaScript" src="../Pluginlab/Scripts/PLVIM.js">/* PLVIMMenu script */</script>
</head>
<body onLoad="PLVIM_onload()">
<p> <a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, 0, $queryString_listeventes); ?>">Premier</a><a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, $totalPages_listeventes, $queryString_listeventes); ?>"> Précédent</a><a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, $totalPages_listeventes, $queryString_listeventes); ?>"> Suivant</a><a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, $totalPages_listeventes, $queryString_listeventes); ?>"> Dernier</a></p>
<p> </p>
<table width="996" border="1" bordercolor="#000000" bgcolor="#99CCFF">
<tr>
<td width="109"><div align="left">ID</div></td>
<td width="124"><div align="center">NOM</div></td>
<td width="160"><div align="center">ADRESSE</div></td>
<td width="144"><div align="center">NATURE</div></td>
<td width="159">debut</td>
<td width="120">fin</td>
<td width="134"><div align="center">MOTIF</div></td>
</tr>
<?php do { ?>
<tr bgcolor="<?php
if($SSAdv_m1%$SSAdv_change_every1==0 && $SSAdv_m1>0){
$SSAdv_k1++;
}
print $SSAdv_colors1[$SSAdv_k1%count($SSAdv_colors1)];
$SSAdv_m1++;
?>">
<td><?php echo $row_listeventes['id']; ?></td>
<td><?php echo $row_listeventes['nom']; ?></td>
<td><?php echo $row_listeventes['adresse']; ?></td>
<td><?php echo $row_listeventes['nature']; ?></td>
<td><?php echo $row_listeventes['ddebut']; ?></td>
<td><?php echo $row_listeventes['dfin']; ?></td>
<td><?php echo $row_listeventes['motif']; ?></td>
</tr>
<?php } while ($row_listeventes = mysql_fetch_assoc($listeventes)); ?>
</table>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($listeventes);
?>
J'ai trouvé sur ce forum des fonctions me permettant de d'arriver au résultat mais je ne m'y connais pas assez. (
http://www.phpfrance.com/forums/viewtop ... =date++sql) Quelqu'un pourrait il me donner un coup de main ?
Merci
Bonjour,
je fait un petit site avec une liste de ventes. Mon problème c est l'affichage et la saisie des dates au format fr.
[code]<?php require_once('../bouton/ventes.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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$SSAdv_colors1 = array("#FFFFCC","#999999");
$SSAdv_k1 = 0;
$SSAdv_m1 = 0;
$SSAdv_change_every1 = 1;
$maxRows_listeventes = 10;
$pageNum_listeventes = 0;
if (isset($_GET['pageNum_listeventes'])) {
$pageNum_listeventes = $_GET['pageNum_listeventes'];
}
$startRow_listeventes = $pageNum_listeventes * $maxRows_listeventes;
mysql_select_db($database_gilles, $gilles);
$query_listeventes = "SELECT * FROM ventes ORDER BY id ASC";
$query_limit_listeventes = sprintf("%s LIMIT %d, %d", $query_listeventes, $startRow_listeventes, $maxRows_listeventes);
$listeventes = mysql_query($query_limit_listeventes, $gilles) or die(mysql_error());
$row_listeventes = mysql_fetch_assoc($listeventes);
if (isset($_GET['totalRows_listeventes'])) {
$totalRows_listeventes = $_GET['totalRows_listeventes'];
} else {
$all_listeventes = mysql_query($query_listeventes);
$totalRows_listeventes = mysql_num_rows($all_listeventes);
}
$totalPages_listeventes = ceil($totalRows_listeventes/$maxRows_listeventes)-1;
$queryString_listeventes = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_listeventes") == false &&
stristr($param, "totalRows_listeventes") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_listeventes = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_listeventes = sprintf("&totalRows_listeventes=%d%s", $totalRows_listeventes, $queryString_listeventes);
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Liste des ventes</title>
<style type="text/css">
<!--
body,td,th {
color: #000066;
}
body {
background-color: #FF9933;
}
-->
</style>
<script src="../bouton/AC_RunActiveContent.js" type="text/javascript"></script>
<script id="PLVIMScript" language="JavaScript" src="../Pluginlab/Scripts/PLVIM.js">/* PLVIMMenu script */</script>
</head>
<body onLoad="PLVIM_onload()">
<p> <a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, 0, $queryString_listeventes); ?>">Premier</a><a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, $totalPages_listeventes, $queryString_listeventes); ?>"> Précédent</a><a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, $totalPages_listeventes, $queryString_listeventes); ?>"> Suivant</a><a href="<?php printf("%s?pageNum_listeventes=%d%s", $currentPage, $totalPages_listeventes, $queryString_listeventes); ?>"> Dernier</a></p>
<p> </p>
<table width="996" border="1" bordercolor="#000000" bgcolor="#99CCFF">
<tr>
<td width="109"><div align="left">ID</div></td>
<td width="124"><div align="center">NOM</div></td>
<td width="160"><div align="center">ADRESSE</div></td>
<td width="144"><div align="center">NATURE</div></td>
<td width="159">debut</td>
<td width="120">fin</td>
<td width="134"><div align="center">MOTIF</div></td>
</tr>
<?php do { ?>
<tr bgcolor="<?php
if($SSAdv_m1%$SSAdv_change_every1==0 && $SSAdv_m1>0){
$SSAdv_k1++;
}
print $SSAdv_colors1[$SSAdv_k1%count($SSAdv_colors1)];
$SSAdv_m1++;
?>">
<td><?php echo $row_listeventes['id']; ?></td>
<td><?php echo $row_listeventes['nom']; ?></td>
<td><?php echo $row_listeventes['adresse']; ?></td>
<td><?php echo $row_listeventes['nature']; ?></td>
<td><?php echo $row_listeventes['ddebut']; ?></td>
<td><?php echo $row_listeventes['dfin']; ?></td>
<td><?php echo $row_listeventes['motif']; ?></td>
</tr>
<?php } while ($row_listeventes = mysql_fetch_assoc($listeventes)); ?>
</table>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($listeventes);
?>[/code]
J'ai trouvé sur ce forum des fonctions me permettant de d'arriver au résultat mais je ne m'y connais pas assez. (http://www.phpfrance.com/forums/viewtopic.php?t=30232&highlight=date++sql) Quelqu'un pourrait il me donner un coup de main ?
Merci