Re: [PHP] How can I write in a loop??
On Friday 28 June 2002 17:31, sunny AT wde wrote: > my bad. I edited to strip out some of the html and left that in there > by mistake. > > the code works as i said, but only to write the first time ti loops, > and doesn't add in anything after. I would suggest posting your full code. Unless it's very large. In which case you should debug by starting with a simple loop. get it working, then build on it: while ($r = mysql_fetch_array($result)) { print_r($r); } -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* As flies to wanton boys are we to the gods; they kill us for their sport. -- Shakespeare, "King Lear" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How can I write in a loop??
my bad. I edited to strip out some of the html and left that in there by mistake. the code works as i said, but only to write the first time ti loops, and doesn't add in anything after. sunny --- Martin Towell <[EMAIL PROTECTED]> wrote: > Is this a direct copy of what you've got? If so, line 11 shouldn't > be there > > -Original Message- > From: sunny AT wde [mailto:[EMAIL PROTECTED]] > Sent: Friday, June 28, 2002 1:24 PM > To: [EMAIL PROTECTED] > Subject: [PHP] How can I write in a loop?? > > > Hi all, > > would be very greatful if someone could hlp. Basically I want to > extract information from Mysql, and then write it to a file. > > I can write state pieces of text, but having trouble with writing > when the information comes out in a while loop. This is what I > hhave > so far: > > > $result=mysql_query("SELECT topicid FROM $topicdb limit 50"); > > $file_name = "topics.html"; > $file_pointer = fopen($file_name, "w"); > > while ($r = mysql_fetch_array($result)) { > extract($r); > > $the_text = "$topicid"; > fwrite($file_pointer, $the_text); > "; > } > > fclose($file_pointer); > print "data written to file successfuly"; > > > but that doesn't seem to work, it only writes the first time, and > doesn't add the rest of the loops. anyone help please? > > sunny > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How can I write in a loop??
Is this a direct copy of what you've got? If so, line 11 shouldn't be there -Original Message- From: sunny AT wde [mailto:[EMAIL PROTECTED]] Sent: Friday, June 28, 2002 1:24 PM To: [EMAIL PROTECTED] Subject: [PHP] How can I write in a loop?? Hi all, would be very greatful if someone could hlp. Basically I want to extract information from Mysql, and then write it to a file. I can write state pieces of text, but having trouble with writing when the information comes out in a while loop. This is what I hhave so far: $result=mysql_query("SELECT topicid FROM $topicdb limit 50"); $file_name = "topics.html"; $file_pointer = fopen($file_name, "w"); while ($r = mysql_fetch_array($result)) { extract($r); $the_text = "$topicid"; fwrite($file_pointer, $the_text); "; } fclose($file_pointer); print "data written to file successfuly"; but that doesn't seem to work, it only writes the first time, and doesn't add the rest of the loops. anyone help please? sunny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php