Page 1 sur 1

faire des sous totaux dans un tableau en fonction de regroup

Posté : 11 mai 2007, 23:45
par finceo
// voici le code pour faire le tableau mais une erreur se produit a chaque fois, pouvez vous m'aider ou me proposer une methode pour faire des sous totaux dans un tableau en fonction de regroupements hierarchiques

[code]
<?php require_once('../Connections/BDD.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;
}
}

mysql_select_db($database_BDD, $BDD);
$query_Rs1 = "SELECT aaa_intervention.id_intervention, aaa_intervention.id_user, aaa_intervention.id_mission, aaa_intervention.date_intervention, aaa_intervention.heure_intervention, aaa_intervention.commentaire, aaa_intervention.validee, aaa_mission.budget, aaa_user.nom_collab, aaa_user.prenom_collab, aaa_user.txhoraire, aaa_client.nom_client, aaa_mission.type_mission, aaa_user.txhoraire*aaa_intervention.heure_intervention AS couhoraire FROM (((aaa_intervention LEFT JOIN aaa_mission ON aaa_mission.id_mission=aaa_intervention.id_mission) LEFT JOIN aaa_client ON aaa_client.id_client=aaa_mission.id_client) LEFT JOIN aaa_user ON aaa_user.id_user=aaa_intervention.id_user) ORDER BY aaa_intervention.date_intervention ASC, aaa_user.nom_collab DESC, aaa_mission.type_mission DESC ";
$Rs1 = mysql_query($query_Rs1, $BDD) or die(mysql_error());
$row_Rs1 = mysql_fetch_assoc($Rs1);
$totalRows_Rs1 = mysql_num_rows($Rs1);
?>
<!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=utf-8" />
<title>Tableau Recap</title>
</head>

<body>
<table border="1">
<tr>
<td>date_intervention</td>
<td>heure_intervention</td>
<td>commentaire</td>
<td>validee</td>
<td>budget</td>
<td>nom_collab</td>
<td>prenom_collab</td>
<td>txhoraire</td>
<td>nom_client</td>
<td>type_mission</td>
<td>couhoraire</td>
</tr>
<?php $i=0;
mysql_data_seek($Rs1, $i);
$totgen=0;

if ($totalRows_Rs1 !== 0)
{

while ($i<=($totalRows_Rs1-1))
{
$totmission=0;
$sauvmission=$row_Rs1['type_mission'];
while (($sauvmission==$row_Rs1['type_mission']) and ($i<=($totalRows_Rs1-1)))
{
$totcollab=0;
$sauvcollab=$row_Rs1['nom_collab'];
while (($i<=($totalRows_Rs1-1)) and ($sauvmission==$row_Rs1['type_mission']) and ($sauvcollab=$row_Rs1[ 'nom_collab']))
{ $totcollab=$totcollab+$row_Rs1['couhoraire'];
echo "<tr>".$row_Rs1['couhoraire']."</tr>";
$i=$i+1;
if ($i<=$totalRows_Rs1-1) { mysql_data_seek($Rs1, $i);?>

<tr>
<td><?php echo $row_Rs1['date_intervention']; ?></td>
<td><?php echo $row_Rs1['heure_intervention']; ?></td>
<td><?php echo $row_Rs1['commentaire']; ?></td>
<td><?php echo $row_Rs1['validee']; ?></td>
<td><?php echo $row_Rs1['budget']; ?></td>
<td><?php echo $row_Rs1['nom_collab']; ?></td>
<td><?php echo $row_Rs1['prenom_collab']; ?></td>
<td><?php echo $row_Rs1['txhoraire']; ?></td>
<td><?php echo $row_Rs1['nom_client']; ?></td>
<td><?php echo $row_Rs1['type_mission']; ?></td>
<td><?php echo $row_Rs1['couhoraire']; ?></td>
</tr>

<?php $row_Rs1= mysql_fetch_assoc($Rs1);
}
}
}
}
} ?>
</table>
</body>
</html>
<?php
mysql_free_result($Rs1);
?>[/code]

Re: faire des sous totaux dans un tableau en fonction de reg

Posté : 12 mai 2007, 01:51
par dunbar
Encore un touriste :!: :!:
Bonjour ---> Absent
Balises ---> Absente
Merci ---> Absent

Tu va te faire des copains ici :wink:

Posté : 14 mai 2007, 08:32
par lem
Au passage, comment se fait-il que ses balises "code" n'aient pas fonctionné ? Le contenu est trop long peut-être ?