Hey. I have a question that may be simple to some but has confused me.
I have a script that queries a database and pulls a list of names out of the table. The query is fine i have it echoed on my page above were the txt file is included so i can compare the two results
I am trying to get it so that when i submit a form on the page. it writes the values of the db query into the file. so far i have had only success... just briefly with writing to the end of the file so it doesnt erase what it has already written in that session.
what i want basically is for the content of my bd query to be written to a txt file so the txt file is updated whenever i submit the form. also if possible id like the script to create the file if it isnt already there.
so far i have:
// if the button is pressed
// write to the file
$fp = fopen( "names.txt" , "a+" );
while ($i < $num)
$name = mysql_result($result,$i,"name");
fwrite( $fp, $name );
fclose( $fp );
// do nothing
$i is declared above and is used to compare the number of rows with the counter.
any help would be great. thanks