I need a bit of code, I haven't learnt much PHP yet.
I have a news script, it is pretty simple and uses MySQL backend. Now I would like to have a Turn On/Off function in the Admin Control Panel. I suppose I would have to create a table for it in PHPMyAdmin.
Let me explain it a bit more...
If in the admin control panel the News is set to "1" (or "on"), the news on index.php would display the news.
But, if it is set to "0" (or "off"), the index.php would display:
News has been disabled.
Here is the code for the news:
<?php
include ('mysql_connect.php');
$query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts ORDER BY id DESC LIMIT 4";
$result = @mysql_query($query);
if ($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$url = 'comments.php?id='.$row['id'];
$row['id'] = array_reverse($row);
echo '<p><b>'.$row['title'].'</b><br />
'.$row['sd'].'<br />
Posted by : <b>'.$row['author'].'</b><br />
'.$row['post'].'<br />';
}
} else {
echo 'There are no news posts to display';
}
?>
Thanks.
Edited by jold101, 31 March 2007 - 09:32 AM.
