<?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>";
?> 

Hi everyone, i ask for your help because that's the first time i have to export it, after reading some comment and some document, i' able to export data from one table but this case is different, i combine different tables in the query. is there any easiest way to get the data in order to export them. please me...

Take a moment to read what you are asking and then read in wikipedia (or anywhere) what is html and what is excel. So the problem is producing the html table or do you really want to export your data to excel file ? .

Recently I learned that learning curve can be quite flat to people that are smart , but have no real interest to learn something new.

You could create a temporary table (using PHP) to combine the data from the other tables and then export that using PHPMyAdmin. You can also create a report putting the data into an HTML table and then write that to excel (if you want to avoid the manual intervention).

Thanks Chrishea, i'll try it like you said.

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.