export sql data in cvs format
<p>I have a table name tblstuden. It contains ids studentname, rollnumberm and classname. I want to download this data in CSV format. How is it possible?</p>

<p>I can upload the data into the table by CSV file. To upload the code is below. It's working for me. But now I want to download the data in CSV format.</p>

<pre><code>&lt;?php

if(isset($_POST['submit']))
{
    $row = 1;
$file1 = $_FILES['file']['tmp_name'];
$file = fopen($file1, "r");
while (($data = fgetcsv($file, 8000, ",")) !== FALSE) {
    $num = count($data);
    $row++;
    for ($c=0; $c &lt; $num; $c++) {
       $data[$c];}
    echo $data[0];

    $name = $data[0];
    }

fclose($file); 
?&gt;
</code></pre>
