News Posting Script

TKCDesigns

New Member
Hi Guys, pretty simple question....Anyone know of a news posting script where I can post news on the front page of my website rather than editting the html everytime?

Thanks,
Tim.
 

thrive

New Member
What languages can you use? The easiest way is to dynamically write to a text file and have the home page read from it. People will suggest using a database but if it's only one file then you don't need to do that.
 

toxic_pmp

New Member
if its in php/mysql then i would you a database!

Use this for the front page where you want it selected

<?php
$usel = mysql_query("select * from news order by id desc limit 10");
while ($upd = mysql_fetch_array($usel)) {
print "<b>$upd[title]</b> by <b>$upd[starter]</b>... \"$upd[news]\"<br><br>";
}

?>


then to put the information into the database use this bit of script ona new page,


<table>
<form method=post action=addnews.php?action=add>
<tr><td>Starter:<td><td><input type=text name=addstarter></td></tr>
<tr><td>Title:</td><td><input type=text name=addtitle></td></tr>
<tr><td valign=top>Update:</td><td><textarea name=addnews rows=5 cols=19></textarea></td></tr>
<tr><td colspan=2 align=center><input type=submit value="Add News"></td></tr>
</form>
</table>

<?php
if ($action == add) {
if (empty ($addtitle) || empty ($addnews)) {
print "You are going to need to fill all fields out to be able to add the news item";
exit;
}
mysql_query("insert into news (starter, title, news) values('$addstarter','$addtitle','$addnews')") or die("Could not add news.");
print "news added was added $addstarter";
}

?>


here is the sql for it


CREATE TABLE `news` (
`id` int(11) NOT NULL auto_increment,
`starter` text NOT NULL,
`title` text NOT NULL,
`news` text NOT NULL,
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

If you need any help just give me a msg i will reply within 24 hours as im on here everyday playing around!
 

thrive

New Member
Why would you use a database when it's just a blurb on the homepage? (Note the last comment I made). If you want to maintain server efficiency you wouldn't do this. Having each hit to the page openning a connection to the database, reading from it, closing it, and posting the results is far to complicated for something like this.
 

toxic_pmp

New Member
no its actually very simple!!! and a good way!!! then u dnt need to go into your host administator login!!! all you need to do is go to a certain page and just simply add the update!!!
 
Last edited:

thrive

New Member
Using a text file or a database would both require you go to a secure page and apply an update. What I'm talking about is the thousands of database connections required each day if your visitors hit it. Using a text file or a xml file would eliminate this need for a connection, thus making the application much more efficient.
 
Top