| | |
download table data from mysql
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 154
Reputation:
Solved Threads: 19
The simplest way to download table data is to use phpMyAdmin.
Matti Ressler
Suomedia
Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Suomedia - Dynamic Content Management
Then I agree with Suomedia. I use SQLYog, though. It's a really nice query analyser type tool that you install on your local PC. It will allow you to do almost anything with your database.
www.webyog.com - there is an enterprise edition and a freebie community edition.
www.webyog.com - there is an enterprise edition and a freebie community edition.
•
•
Join Date: Mar 2008
Posts: 154
Reputation:
Solved Threads: 19
Yes. If you use phpmyadmin you will see it as export options in many formats. One that I commonly use is CSV.
Matti Ressler
Suomedia
Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Suomedia - Dynamic Content Management
•
•
Join Date: Mar 2008
Posts: 154
Reputation:
Solved Threads: 19
Yes, of course it can be done with php. Its quite a bit of code which I don't have the time for, but I am sure somebody else probably will. The web is full of tutorials on how to do this.
Matti Ressler
Suomedia
Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Suomedia - Dynamic Content Management
•
•
Join Date: Jan 2008
Posts: 11
Reputation:
Solved Threads: 0
For future reference for others, this will download as *.csv file. You may change file type and HEADER types, for *.txt
I do not use (or download) any *.txt, so I have not reseached modifying.
I do not use (or download) any *.txt, so I have not reseached modifying.
php Syntax (Toggle Plain Text)
<?php $host = 'localhost'; $user = 'dbUsername'; $pass = 'dbPassword'; $db = 'dbName'; $table = 'dbTable'; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field']."; "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j]."; "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?>
![]() |
Similar Threads
- Apache (Linux Servers and Apache)
- mysql loading txt file to mysql db????????? (MySQL)
- Firefox keeps opening multiple tabs by itself everytime I open Firefox (Viruses, Spyware and other Nasties)
- Data from mysql in a 3 columns table (PHP)
- Problems using a php generator (PHP)
- Irritating virus.. the same as "Virus Alert!" (Viruses, Spyware and other Nasties)
- IE redirecting to other site from any Google result (Viruses, Spyware and other Nasties)
- Great Plan.exe (Viruses, Spyware and other Nasties)
- radio button ASP question?? (ASP)
Other Threads in the PHP Forum
- Previous Thread: Creating a 6 digit number from letters
- Next Thread: PHP and Checkboxes in email
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube





