HI All,

I am working first time on CSV files. I want to fetch record or value which are coming from database in php. I want to fetch these all value in CSV file or excel spreadsheet. Please help me . How i can do this.Its very urgent for me.


hi, check out this attachments, in dump_not1.php page edit the sql code and give a link to that page

<a href="dump_not1.php?type=1" class="slinks">Download To CSV </a>

you will get it

This is the code that i used for converting .csv to .xls...I think this may help you.

header("Content-Disposition:attachment;filename='csv to excel'");
    $open = fopen("phpex1.csv", "a+"); //open the csv file
    echo "<table border='1'>";
    echo "<tr><td colspan='15'><h1><center>.csv to .xls</center></h1></td></tr>";
    while (($data = fgetcsv($open," ", ",")) !== FALSE) 
            $num = count($data); //get number of data in a line
            echo "<tr>";
                for ($c=0; $c < $num; $c++){
                    echo "<td>";     
                    echo $data[$c]; // data that are get entered into the table
                    echo "</td>";
            echo "</tr>";
    fclose($open); //close the file
    echo "</table>";