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.
Thanks,
Tim.
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 ;