Jump to content

Recommended Posts

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

$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);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.