First, you said you had the import working, but you ended up with double quotes in your values. You can strip those using code like:
[php]
$val = str_replace('"', '', $val);
[/php]
Here is example code that shows you how to connect to a mysql server, select a specific database, execute a SQL statement, then work with the data.
[php]
<?php
$server = "localhost"; // Name or IP of database server.
$user = ""; // username
$pwd = ""; // password
$db = ""; // Name of database to connect to.
if (!$cnn = mysql_connect($server,$user,$pwd )) {
die("mysql_connect() failed");
}
if (!mysql_select_db($db,$cnn)) {
die("Could not select database named ".$db);
}
/* Build your SQL statement however you need. */
$sql = "select * from mytable";
/* Execute the query. */
if (!$res = @mysql_query($sql)) {
die(mysql_error());
return false;
}
/* Create an array of arrays out of the recordset. */
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
$data[] = $row;
}
/* Now iterate through the recordset creating a simple table. */
echo "";
echo "\n";
echo "";
echo "#";
foreach($data[0] as $key=>$val) {
echo "";
echo $key;
echo "";
}
echo "\n";
$row_cnt = 0;
foreach($data as $row) {
$row_cnt++;
echo "";
echo "".$row_cnt."";
foreach($row as $val) {
echo "";
echo $val;
echo "";
}
echo"\n";
}
echo "\n";
?>
[/php]
Next, you need to know how to save the recordset back into a TAB delimited file. This example uses the $data value from the code example above.
[php]
<?php
$fp = fopen("path_to_file_here", "w");
foreach($data as $row) {
$line = "";
foreach($row as $val) {
$line .= "\t\"".$val."\"";
}
/* Strip off the first TAB and add a carriage return. */
$line = substr($line, 1)."\n";
$fwrite($line);
}
fclose($fp);
?>
[/php]
I hope that helps! Enjoy the journey!