Здравейте,
Много съм нов във този бранш но имам желание и полагам усилия за да се науча.
Все още немога да пиша скриптове, а ми трябва един за новини във сайта ми.
Ето скрипта от админ панела на сайта - editnews.php
Във админ панела - pages/add_news.php
Във админ панела - pages/news.php
Фактически ми липсва news.php в директорията на сайта.
Благодаря предварително за вашето съдействие, а аз със сигорност ще го прочета 10 пъти за да видя каде греша.
Много съм нов във този бранш но имам желание и полагам усилия за да се науча.
Все още немога да пиша скриптове, а ми трябва един за новини във сайта ми.
Ето скрипта от админ панела на сайта - editnews.php
PHP:
<?php include('header.php'); ?>
<body>
<div class="container">
<div class="header">
<div class="header_logo">
<a href="index.php"><img src="images/logo.jpg" width="677" height="122" alt="Logo" class="logo" /></a>
<div class="clr"></div>
</div>
</div>
<div class="content">
<div class="content_res">
<div class="leftblock vertsortable">
<div class="gadget">
<div class="titlebar vertsortable_head">
<a href="#" class="hidegadget" rel="hide_block"><img src="images/spacer.gif" alt="picture" width="19" height="33" /></a>
<h3>Редакция на новина</h3>
</div>
<div class="gadgetblock">
<?php
$id = $_GET['id'];
$author = $_GET['author'];
if(isset($_POST['submit'])){
$name = $_POST['name'];
$new = $_POST['new'];
$image = $_POST['image'];
$update = mysql_query("UPDATE news SET name='$name',new='$new',image='$image' WHERE id='$id'");
echo " <div class='error_msg'><p>Новината бе редактирана успешно! Натиснете <a href='admin.php?action=news'>тук</a> за да се върнете назад или <a href='index.php'>тук</a> за да се върнете в началото.</p></div>
";
}
$db = ("SELECT * FROM news WHERE id='$id'");
$results = mysql_query($db);
$row = mysql_fetch_array($results);
$name = $row['name'];
$new = $row['new'];
$author = $row['author'];
$image = $row['image'];
?>
<form method="post" action="">
Заглавие на новината<br />
<input type="text" name="name" value='<? echo"$name"; ?>' style="width: 250px;"> <div class="hr"></div>
Автор<br />
<input type="text" name="author" readonly="readonly" value='<? echo"$author"; ?>' style="width: 160px;"> <div class="hr"></div>
Снимка<br />
<img src="<?php echo $image;?>" border="0"><br />
Линк на изображението
<input type="text" name="image" value='<? echo"$image"; ?>' style="width: 360px;"> <br />
Съдържание на новината<br />
<textarea name="new" style="width: 505px; height: 220px; margin-left: 0;"><? echo"$new"; ?></textarea><br />
<input type="submit" name="submit" value="Редактирай новината"><br>
</form></div>
</div>
</div>
<div class="rightblock vertsortable">
<?php include('inc/right.php'); ?>
</div>
</div>
<div class="clr"></div>
</div>
<?php include('footer.php'); ?>
</div>
</body>
</html>
Във админ панела - pages/add_news.php
PHP:
<form method="post" action="">
Заглавие<br />
<input type="text" name="title" style="width: 505px;"><br />
Автор<br />
<input type="text" name="author" style="width: 160px;"> <br />
Снимка<br />
<input type="text" name="image" style="width: 260px;"> <br />
Текст<br />
<textarea name="new" style="width: 505px; height: 220px; margin-left: 0;"> </textarea> <br /> <br />
<input type="submit" name="addnew" value="Публикувай новината">
</form>
<?
if($_POST['addnew']) {
$title = htmlspecialchars($_POST['title']);
$author = htmlspecialchars($_POST['author']);
$opisanie = $_POST['new'];
$image = $_POST['image'];
$date = date("d/F/Y");
$sql = "INSERT INTO `news` (name, new, image, author, date) VALUES ('$title', '$opisanie', '$image', '$author', '$date')";
$result = mysql_query($sql);
echo " <br /><div class='error_msg'><p>Новината бе добавена успешно! Натиснете <a href='admin.php?action=news'>тук</a> за да се върнете назад или <a href='index.php'>тук</a> за да се върнете в началото.</p></div>";
}
?>
Във админ панела - pages/news.php
PHP:
<a href="index.php"class="colourbutton button_blue"><span><span>Начална страница</span></span></a>
<a href="admin.php?action=addnews"class="colourbutton button_blue"><span><span>Добави новина</span></span></a><br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="gwlines">
<tr>
<th width="10" style="font-size: 13px;">ID</th>
<th width="150" style="font-size: 13px;">Заглавие на новината</th>
<th width="90" style="font-size: 13px;">Автор</th>
<th width="120" style="font-size: 13px;">Дата</th>
<th colspan="2" style="font-size: 13px;">Действие</th>
</tr>
<?php
$sql = "SELECT * FROM news ORDER BY id";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
?>
<tr><td style="font-size: 13px;"><?php echo $row['id']; ?></td>
<td style="font-size: 13px;"><?php echo $row['name']; ?></td>
<td style="font-size: 13px;"><?php echo $row['author']; ?></td>
<td style="font-size: 13px;"><?php echo $row['date']; ?></td>
<td width="28"><a href="editnews.php?id=<?php echo $row['id']; ?>"><img src="images/Pencil.png" alt="picture" width="20" height="20" title="Промени" class="tabpimpa" /></a></td>
<td width="28"><a href="delnews.php?id=<?php echo $row['id']; ?>"><img src="images/pimpa_no.gif" alt="picture" width="20" height="20" title="Изтрии" class="tabpimpa" /></a></td>
</tr>
<?php
}
?>
</table>
Фактически ми липсва news.php в директорията на сайта.
Благодаря предварително за вашето съдействие, а аз със сигорност ще го прочета 10 пъти за да видя каде греша.