acctman Posted May 18, 2009 Share Posted May 18, 2009 how can i make the echo all results at the bottom to a textfile and have it rewrite the text file each time i run the script. $sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username FROM '. FORUMS_TABLE .' f,'.TOPICS_TABLE.' t, '.POSTS_TABLE.' p,'.USERS_TABLE.' u WHERE t.forum_id = f.forum_id AND t.topic_status != 1 AND u.user_id = p.poster_id' . $forum_sql . $topic_sql . (empty($topic_sql) ? ' AND p.post_id = t.topic_last_post_id ' : '') . ' ORDER BY ' . (empty($topic_sql) ? 't.topic_last_post_time DESC' : 'p.post_time DESC') . ' LIMIT 0,' . $topic_limit; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}"; $count = count(@explode($$row['post_subject']," ")); $count = strlen($row['post_subject']) - ( $count - 1 ); $subject = strlen($row['post_subject']) > 30? substr($row['post_subject'],0,27)."...": $row['post_subject']; $count1 = count(@explode($en['m_user']," ")); $count1 = strlen($row['username']) - ( $count - 1 ); $row['username'] = strlen($row['username']) > 12? substr($row['username'],0,9)."...": $row['username']; echo '<div style="padding-bottom:5px;"><a target="_parent" title="'.$row['post_subject'].'" href="' . $url . '">' . $subject . '</a> - ' . $row['username'] . ' : ' . date("D m/d/y, h:ia",$row['post_time']) . ' </div>'; } Link to comment https://forums.phpfreaks.com/topic/158664-solved-echoing-results-to-a-textfile/ Share on other sites More sharing options...
Masna Posted May 18, 2009 Share Posted May 18, 2009 $file_string = '<div style="padding-bottom:5px;"><a target="_parent" title="'.$row['post_subject'].'" href="' . $url . '">' . $subject . '</a> - ' . $row['username'] . ' : ' . date("D m/d/y, h:ia",$row['post_time']) . ' </div>'; file_put_contents("collective_file.txt", $file_string, FILE_APPEND); Link to comment https://forums.phpfreaks.com/topic/158664-solved-echoing-results-to-a-textfile/#findComment-836768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.