geplaatst door: marcone
Hallo,

mijn klant logt nu in via phpmyadmin om een export te doen naar .xls of .csv van de database inhoud.

Vraag:
is er een manier om dit automatisch te doen? Online? wat ik voor me zie is een webpagina met één knopje "genereer", en hoppa, de database wordt ingelezen en vertoont op het scherm.

Kan dit? En zoja, heeft iemand een oplossing hiervoor? Ik ben nogal een n00b mbt tot php, dus een goede jumpstart zou heeeel fijn zijn ;-)

groeten!
Marc

Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
Gezocht: php script wat automatisch database uitleest..
24 juni 2010 - 17:05    reactie #1
geplaatst door: jakkobreed
Kijk even naar dit artikel:
http://www.the-art-of-web.com/php/dataexport/
Daaraan zie je dat er wel wat meer bij komt kijken dan de info welke je geeft.
Maar het is dus wel mogelijk.
Gezocht: php script wat automatisch database uitleest..
24 juni 2010 - 17:06    reactie #2
geplaatst door: Mrmoon
Even een vraag ter verduidelijking: wil je een complete export van alle tabellen in een database in XLS/CSV krijgen of gaat 't om speciefieke data?

Beide is mogelijk, alhoewel het ene wel wat meer werkt vergt dan het andere...

MacBook Pro M1 - 16 Gb Ram - 512 Gb
Mac Studio - M1 MAX - 32 Gb Ram - 512Gb
Mac Mini - M1 - 16 Gb Ram - 256Gb
iPhone - X
Gezocht: php script wat automatisch database uitleest..
25 juni 2010 - 01:03    reactie #3
geplaatst door: marcone
dank jullie voor het duwen in de goede richting! hieronder plak ik de code die ik uiteindelijk heb gebruikt. Klant tikt een url in, sitenaam.nl/export.php en er wordt automatisch een .csv bestand gemaakt en gedownload. Heel erg handig!


<?php<br>$host 'hierje hostnaam zoals bv. localhost';<br>$user 'database username';<br>$pass 'database wachtwoord';<br>$db 'database naam';<br>$table 'tabelnaam in database';<br>$file 'export';<p>$link mysql_connect("hierhostnaam zoals localhost","database username","database wachtwoord") or die("Can not connect." mysql_error());<br>mysql_select_db($db) or die("Can not connect.");<p>$result mysql_query("SHOW COLUMNS FROM ".$table."");<br>$i 0;<br>if (mysql_num_rows($result) > 0) {<br>while ($row mysql_fetch_assoc($result)) {<br>$csv_output .= $row['Field']."; ";<br>$i++;<br>}<br>}<br>$csv_output .= "\n";<p>$values mysql_query("SELECT * FROM ".$table."");<br>while ($rowr mysql_fetch_row($values)) {<br>for ($j=0;$j<$i;$j++) {<br>$csv_output .= $rowr[$j]."; ";<br>}<br>$csv_output .= "\n";<br>}<p>$filename $file."_".date("Y-m-d_H-i",time());<br>header("Content-type: application/vnd.ms-excel");<br>header("Content-disposition: csv" date("Y-m-d") . ".csv");<br>header"Content-disposition: filename=".$filename.".csv");<br>print $csv_output;<br>exit;<br>?>
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
Gezocht: php script wat automatisch database uitleest..
25 juni 2010 - 11:11    reactie #4
geplaatst door: Cailin Coilleach
Citaat
Heel erg handig!

Ik bid tot het hele gesternte aan goden dat je dit achter een .htaccess hebt neer gezet.
Gezocht: php script wat automatisch database uitleest..
25 juni 2010 - 14:34    reactie #5
geplaatst door: marcone
^^ dat klopt helemaal!  Was vannacht toch nog wel een beetje wakker ;-)
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain