Hello friend,

   I have a registration form and a admin panel for that, In admin panel we can see the list of registered users. I can filter user details by search but i cannot export searched results to .xls or .csv format. kindly help me...!!!

Thank you.

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

Maybe google something like html tables to csv. But that is assuming your stuff is in a table as opposed to be styled with css.

Either way if you know what you're doing you can write a rudimentary .csv dump.

Failing that you can look to free excel exporters which would cover more complex examples...

This will export .xls file all you would need to do is create your own query. I created a form with a hidden field value of id number and a download input button, so when user clicks on the download button, the id gets sent to my query and exports the .xls file.

$q = mysql_query("SELECT * FROM tablename WHERE id='$id'");

header( "Content-Type: application/vnd.ms-excel" );
header( "Content-disposition: attachment; filename=spreadsheetfilename.xls" );

echo 'Fieldname' . "\t" . 'Fieldname' . "\t" . 'Fieldname' . "\t" . 'Fieldname' . "\n";
while($res = mysql_fetch_array($q)){
    echo $res['Fieldname'] . "\t" . $res['Fieldname'] . "\t" . $res['Fieldname']. "\t" . $res['Fieldname'] . "\n";
}           
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.