<!-- Load TinyMCE -->
<script type="text/javascript" src="tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
$().ready(function() {
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : 'tiny_mce/tiny_mce.js',
// General options
theme : "advanced",
plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
});
</script>
<?php
if($_REQUEST['do'] == 'add'){
$array = array(
1 => 'Topic',
2 => 'Author',
3 => 'Text',
4 => 'Image_Id',
5 => 'Date',
6 => 'Hide_News',
7 => 'Author_Id');
if ($_POST['Post'])
{
$hide_news =$_POST['hide_news'];
$date =$_POST['date'];
$author =$_POST['author'];
$author_id =$_POST['author_id'];
$image_id =$_POST['image_id'];
$topic =$_POST['topic'];
$text =$_POST['text'];
$p="INSERT INTO z_news_big(hide_news,date,author,author_id,image_id,topic,text) values('$hide_news','$date','$author','$author_id','$image_id','$topic','$text')";
$execute = $mysqli->query($p);
echo "<b>Thank you! News added Successfully!<br>You'll be redirected to Home Page after (1) Seconds";
echo "<meta http-equiv=Refresh content=1;url=?page=news&do=index>";
}
else
{
print "<form action='$PHPSELF' method='POST'>";
print "$array[1] - <input type='text' name='topic'><br />";
print "$array[3] - <textarea id='elm1' name='text' style='width: 100%' class='tinymce'></textarea><br />";
print "$array[6] - <input type='text' name='hide_news'><br />";
print "$array[5] - <input type='text' name='date'><br />";
print "$array[2] - <input type='text' name='author'><br />";
print "$array[7] - <input type='text' name='author_id'><br />";
print "$array[4] - <input type='text' name='image_id'><br />";
print "<input type='submit' name='Post' value='Post News!'><br />";
}
}
if($_REQUEST['do'] == 'delete')
{
// $result = $mysqli->query("DELETE FROM `z_news_big` WHERE `z_news_big`.`hide_news` = '$hide_news' AND `z_news_big`.`date` = '$date' AND `z_news_big`.`author_id` = '$author_id' AND `z_news_big`.`image_id` = '$image_id' AND `z_news_big`.`topic` = '$topic' AND `z_news_big`.`text` = '$text' LIMIT 1");
$mysqli->query('DELETE FROM `z_news_big` WHERE `date` = '.$date);
echo "<b>News Deleted!<br>You'll be redirected to Home Page after (1) Seconds";
//header("location: index.php");
echo "<meta http-equiv=Refresh content=1;url=?page=news&do=index>";
}
$array = array(
'1' => 'Topic',
'2' => 'Author',
'3' => 'Image_Id',
'4' => 'Hide_News');
if($_REQUEST['do'] == 'index')
{
?>
<a href="?page=news&do=add">Add News</a>
<style>
._table { border: 2px solid #98bcdf; background-color:#ffffff; padding:0px; border-collapse:collapse; margin-left: auto; margin-right: auto;}
._th { background: url(images/header_background.gif) repeat-x right bottom; background-color: #ffffff; border: 1px solid #688caf; padding:4px; padding-right: 5px; padding-left: 5px; font-weight: bold; font-size: 13px; color: #333333; text-align: center; white-space: nowrap; width: 1%; margin-left: auto; margin-right: auto;}
._td { border-right: #d0d7e5 1px solid; border-left: #d0d7e5 1px solid; border-bottom: #d0d7e5 1px solid; padding-right: 4px; padding-left: 5px; padding-bottom: 2px; padding-top: 3px; white-space:nowrap; text-align:center; margin-left: auto;margin-right: auto; }
._tr {background: none repeat scroll 0% 0% rgb(247, 249, 251);}
</style>
<table align="center" width="95%" class="_table" id="prd__contentTable" dir="ltr">
<thead>
<tr class="dg_tr">
<th class="_th">#</th>
<th class="_th">Title</th>
<th class="_th">Author</th>
<th class="_th">Image_Id</th>
<th class="_th">Hide_News</th>
<th class="_th">Text</th>
<th class="_th">Date</th>
<th class="_th">Action</th>
</tr>
</thead>
<?PHP
$i=1;
$data = $mysqli->query("SELECT * FROM `z_news_big`");
while($item = $data->fetch_array()){
echo "<tr class='_tr'><td class='_td'>".$i."</td>";
echo "<td class='_td'>".$item['topic']."</td>";
echo "<td class='_td'>".$item['author']."</td>";
echo "<td class='_td'>".$item['image_id']."</td>";
echo "<td class='_td'>".$item['hide_news']."</td>";
echo "<td class='_td'><textarea cols=30 rows=5>".$item['text']."</textarea></td>";
echo "<td class='_td'>".$item['date']."</td>";
echo "<td class='_td'>Delete : <a href='?page=news&do=delete'>Delete</a></td></tr>";
$i++;
}
unset ($data);
}
?>
</table>