Forum Moderators: coopster
try this page
[dev.mysql.com...]
look for select into outfile and mysqldump they offer some solutions
there are really a ton of ways to do it
you can grab it all from mysql with php and pretty much write it in any format you want, doesn't even take much time.
but...it depends on what you are planning to do with it.
If you want to use it to put back into mysql at a later date, such as a backup or moving servers, then mysqldump is your best bet
if you want to put it into excel or something then write it out as a csv
endless possibilities ;)
I have looked at what you suggested but since I am new at php I could not follow what the site was saying. Maybe if I can explain myself better you will get a better Idea.
So far I got
<?php
require_once 'db_connect.php';
/// older stuff
$result = mysql_query( "SELECT * FROM categories" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
$category_code=mysql_result($result,"category_code");
$category_name=mysql_result($result,"category_name");
$category_id=mysql_result($result,"category_id");
$category_display=mysql_result($result,"category_display");
$entry_line = "Name: $category_name\n Code: $category_code \n ID: $category_id\n Display: $category_display \n";
$fp = fopen("logs1.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
?>
I manages to create the logs1.txt and it writes to it as in the Name: Code etc... but all the entries have the number 3 next to them (first category_id in the database) and nothing else.
Basically I need the script to output all the data in one table as a friend of mine requires it to do some java script work.
Any help would be greatly appreciated.
See if this helps:
...
$result = mysql_query( "SELECT * FROM categories")
or die("SELECT Error: ".mysql_error());
$entry_lines = "";
while ($query_data = mysql_fetch_array($result)) {
$entry_lines .= "Name: ".$query_data['category_name']."\n";
$entry_lines .= "Code: ".$query_data['category_code']."\n";
$entry_lines .= "ID: ".$query_data['category_id']."\n";
$entry_lines .= "Display: ".$query_data['category_display']."\n\n";
)
$fp = fopen("logs1.txt", "w");
fputs($fp, $entry_lines); // fwrite() alias
fclose($fp);
...
or, you can always do mysqldump from the command line:
mysqldump -hlocalhost -ubeinghuman -p database_name.categories -> logs1.txt
...then put the file in a word processor and search and replace to get the format you want.