Hello - My brain has 'mushified' and I'm stuck
I'm trying to two things
#1 - take query results and output to an XML file (working fine)
#2 - take the same results and write them to a text file (not so good)
I can write a single cell to the file - but not the whole "returned set" of data
I was hoping a new set of eyes could point me in the right direction
How do I write all of the data returned from the query, to the text file??
THANK YOU for your time in looking, I do appreciate it :o
Here is the code I'm using
::::::::::::::::::::::::::::::
//for the output
header("Content-type: text/xml");
//to create connection to database
$connection = mysql_connect("localhost","USERNAME","PASSWORD")
or die ("could not connect to database");
//select the database here
$db = mysql_select_db("DATABASE",$connection)
or die ("Couldn't select database.");
$rs = mysql_query("select tour.tourid, tour.mls, tour.userid from tour",$connection)
or die ("invalid query");
//count the no. of columns in the table
$fcount = mysql_num_fields($rs);
//name for the starting XML tag
echo ("<item>");
while($row = mysql_fetch_array( $rs ) )
{
echo ("<coldwell>");
for($i=0; $i< $fcount; $i++)
{
$tag = mysql_field_name( $rs, $i );
echo ("<$tag>". $row[$i]. "</$tag>");
}
echo ("</coldwell>");
}
echo ("</item>");
// query results to be written to file
:glare:$results = mysql_result($rs, 2);:glare:
// open or create file to write to
$fp = fopen("static.txt", "w");
// write query results to the static.txt file
fwrite($fp, $results);
fclose($fp);