<?php
include ('pages/dbconnect.php');
$rekdep=mysql_query("SELECT * FROM t_org ORDER BY dept, com ASC");
echo "<table class='gridtable'>";
echo "<tr><tr><th> Departement</th><th> Commune </th><th> ORG </th><th>Animal</th>";
echo "</tr>";
echo "</tr>";
$odl_dept = null;
$odl_com = null;
$odl_org = null;
while($dep=mysql_fetch_assoc($rekdep)){
//List of department
if($dep['dept']!=$odl_dept){
echo "<td>".$dep['dept']."</td>";
}
//display blank td if the same department is found a second time
else{echo "<td></td>";}
//List of commune
if($dep['com']!=$odl_com){
echo "<td>".$dep['com']."</td>";
}
//display blank td if the same commune is found a second time
else{echo "<td></td>";}
// list of organizations
if($dep['nom']!=$odl_org){
echo "<td>".$dep['nom']."</td>";
$org= $dep['nom'];
//display the number of animal for each organization
$qcab= mysql_query("SELECT sum(`qte_an`) FROM `t_animal` WHERE ((org= '$org') AND (nom_an='Cabrit'))") or die(mysql_error());
$arr_cab = mysql_fetch_array($qcab);
$qte_cab = $arr_cab[0];
echo "<td>"; echo $qte_cab; echo "</td>";
}
echo "</tr>";
$odl_dept = $dep['dept'] ;
$odl_com = $dep['com'] ;
$odl_org = $dep['nom'] ;
}
echo "</table>";
?>
Belton 0 Newbie Poster
Belton 0 Newbie Poster
jkon 636 Posting Whiz in Training Featured Poster
chrishea 182 Nearly a Posting Virtuoso
mglobs 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.