sorry fixed the links
code will be something like
open file
open db and suck data into a string for each row
fwrite each string into the text file
next record
close the text file
$filename = 'test.txt';
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
//db connection stuff here
$result = mysql_query("select * from table") or die("can't query ".mysql_error());
while ($rows=mysql_fetch_array($result)){
$yy=0;
for ($x=0;$x, $x< mysql_num_fields($result)-1);$x++){
if ($yy ==0){
$somecontent = $rows[x];
$yy=1;
}else{
$somecontent.=",".$rows[x]
}//end if
}//next
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
$somecontent=""; //reset the variable to nothing
}//end while
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>