Forum Moderators: coopster
I'm creating a sites of the week functionality, and I'm having some trouble writing items from DB onto a separate line.
I've tried using \r and \n but that doesn't seem to work.
Any ideas?
$_file1 = 'site_of_the_week_1.txt';
$_fp1 = @fopen( $_file1, 'w' );
$site_of_week_1=mysql_query("select title,url
from db_links
where catid=$sub_catid
order by rand() limit 3");
while (list($DBtitle,$DBurl)=mysql_fetch_row($site_of_week_1))
{
$_text1 =$DBtitle.','.$DBurl.','.'\r\n';
@fwrite( $_fp1, $_text1 );
}
@fclose( $_fp1 );
$allfiles1 = file ("$base_url/site_of_the_week_1.txt");
Many Thanks
Woldie.
Here's the solution:
$_file1 = 'site_of_the_week_1.txt';
$_fp1 = @fopen( $_file1, 'w' );
$site_of_week_1=mysql_query("select title,url
from db_links
where catid=$sub_catid
order by rand() limit 3");
while (list($DBtitle,$DBurl)=mysql_fetch_row($site_of_week_1))
{
$_text1 =$DBtitle.','.$DBurl.','."\r\n";
@fwrite( $_fp1, $_text1 );
}
@fclose( $_fp1 );
$allfiles1 = file ("$base_url/site_of_the_week_1.txt");
Looks like you have to place \r\n in double quotes!
Woldie.
Strings [php.net]