Файл: WORLDofTANKS/test/adg/news.php
Строк: 18
<?php
if (isset($_POST['text'])) {
$text = $_POST['text'];
$title = $_POST['title'];
$date = time();
$qwe = mysql_query("INSERT INTO news (date,title,text) VALUES ('$date','$title','$text')") or mysql_error();
echo "Новость добавлена";
}
if(isset($_POST['id'])) {
$id = $_POST['id'];
$asd = mysql_query("DELETE FROM news WHERE id = $id") or mysql_error();
echo "Удалена новость №".$id;
}
?>
<form method="post" action="">
<input type="text" name="title">
<br>
<textarea name="text" rows="7" cols="40">Text</textarea> <br>
<input type="submit" value="Создать">
</form>
<br>
<table align="center" border="1" style="width:700px;">
<tr>
<td>Дата</td>
<td>Тема</td>
<td>Новость</td>
<td>Удалить</td>
</tr>
<?
$con = mysql_query("SELECT * FROM news");
while($c = mysql_fetch_array($con)) {
$date = date("d-M-y", $c['date']);
?>
<form method="post" action="">
<tr>
<input type="hidden" name="id" value="<?=$c['id']; ?>">
<td><?=$date; ?></td>
<td><?=$c['title']; ?></td>
<td><?=$c['text']; ?></td>
<td><input type="submit" value="Удалить"></td>
</tr>
</form>
<? } ?>
</table>