GetDotted Domains

Viewing Thread:
"php news"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sun 26/05/02 at 14:00
Regular
Posts: 787
I've got a php news script on my site, it works well, except for the fact that the new news is entered at the bottom of the page and the old news stays at the top.
So, unless I edit the news data to turn the tables around everytime I enter some news it will stay the same.
Is there a script I can enter to flip the tables around or so that next time I enter some news in it enters it into the top instead of the bottom? thanks.

news script: http://membres.lycos.fr/enterthefog/update/news.php
Sun 26/05/02 at 14:49
Posts: 0
Turbonutter wrote:
> $fp = fopen( "news.txt", 'a' );
>
> Change to the "a" to "r+", see about that.

Tried that. Didn't work, it overwrites instead.
Sun 26/05/02 at 14:47
Regular
"Eff, you see, kay?"
Posts: 14,156
$fp = fopen( "news.txt", 'a' );

Change to the "a" to "r+", see about that.
Sun 26/05/02 at 14:45
Posts: 0
OK, I've got it for you... Sorry bout posting all this code, i just thought it'd be easier. basically it just reads the content of the file as it is at the moment, then adds that onto the end.

--------------------------

print "

Submit News

";
if ( isset($actionflag) && $actionflag == "join")
{
if ( ! file_exists("news.txt") )
{
touch("news.txt");
}

$fopen_contents = fopen ("news.txt", "r");
$fread_contents = fread ($fopen_contents, filesize ("news.txt"));
fclose ($fopen_contents);

$fp = fopen( "news.txt", 'w' );
fwrite ( $fp, "
");
fwrite ( $fp, "$form[subject]
" );
fwrite ( $fp, "Posted by $form[author]
" );
fwrite ( $fp, "$form[text]" );
fwrite ( $fp, "
\n");
fwrite ( $fp, $fread_contents);
print "News Sent!";
}
if ( isset($clearflag) && $clearflag == "clear")
{
unlink("News.txt");
touch("News.txt");
print "Database reset!";
}
?>
Sun 26/05/02 at 14:39
Regular
"IT'S ALIVE!!"
Posts: 4,741
It's not Mysql

ok, ok i'll post the script:

print "

Submit News

";
if ( isset($actionflag) && $actionflag == "join")
{
if ( ! file_exists("news.txt") )
touch("news.txt");
$fp = fopen( "news.txt", 'a' );
fwrite ( $fp, "
");
fwrite ( $fp, "$form[subject]
" );
fwrite ( $fp, "Posted by $form[author]
" );
fwrite ( $fp, "$form[text]" );
fwrite ( $fp, "
\n");
print "News Sent!";
}
if ( isset($clearflag) && $clearflag == "clear")
{
unlink("pages/news.txt");
touch("pages/news.txt");
print "Database reset!";
}
?>
Sun 26/05/02 at 14:33
Regular
"Eff, you see, kay?"
Posts: 14,156
Right, what you need to do is sort through all the code and find the EXACT MySQL query that fetches the data from the table to display on the page. This shouldn't be hard. You need to tack this on to the end of the query:

ORDER by DESC

(or ASC, I can't be bothered to work it out)

This is assuming you know something about MySQL :) If not, just paste the query here and I'll modify it for you.
Sun 26/05/02 at 14:28
Regular
"IT'S ALIVE!!"
Posts: 4,741
I don't want to spam the thread up with the full code, could you download: http://membres.lycos.fr/enterthefog/update/news.zip

the file is called npost.php it's one of two files :)
Sun 26/05/02 at 14:19
Regular
"It goes so quickly"
Posts: 4,083
Have you got the PHP Code bit, which adds the Text to the file???
Sun 26/05/02 at 14:17
Regular
"IT'S ALIVE!!"
Posts: 4,741
the actual script is very small, it's mostly all tables, it stores the info for the page you see when your updating:
Title Date
text..........

and for what you see on the news page where it's all updated to.



Date:


Subject:


News:











thats the whole thing, including the updating page.
Sun 26/05/02 at 14:14
Regular
"It goes so quickly"
Posts: 4,083
Is it a big Script????
Sun 26/05/02 at 14:13
Regular
"IT'S ALIVE!!"
Posts: 4,741
I know next to nothig about php, I was just hoping there was something I could change in the script to make the old news move down :)

atm it write all the news to a text file, it's all stored in there.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thanks!
Thank you for dealing with this so promptly it's nice having a service provider that offers a good service, rare to find nowadays.
Many thanks!!
Registered my website with Freeola Sites on Tuesday. Now have full and comprehensive Google coverage for my site. Great stuff!!
John Shepherd

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.