
05.04.2008, 14:52
|
|
Познавший АНТИЧАТ
Регистрация: 23.08.2007
Сообщений: 1,237
Провел на форуме: 18127311
Репутация:
1676
|
|
Попробуй это (все одним файлом):
PHP код:
<?
if(isset($_GET['add']))
{
print '
<form method="post">
<table border="1">
<tr>
<td>Картинка</td>
<td><input type="text" name="pic"></td>
</tr>
<tr>
<td>Название статьи</td>
<td><input type="text" name="sname"></td>
</tr>
<tr>
<td>Информация</td>
<td><input type="text" name="info"></td>
</tr>
<tr>
<td>Cсылка</td>
<td><input type="text" name="link"></td>
</tr>
</table>
<input type="submit" value="Создать">
</form>
';
}
if(isset($_POST['pic']) && isset($_POST['sname']) && isset($_POST['info']) && isset($_POST['link']))
{
$pic = $_POST['pic'];
$sname = $_POST['sname'];
$info = $_POST['info'];
$link = $_POST['link'];
$fh = fopen('base.txt', 'a') or die("Can't open file");
fwrite($fh,$pic.";;".$sname.";;".$info.";;".$link."\n");
fclose($fh);
}
if(isset($_GET['show']))
{
print '
<table border="1">
<tr>
<th>Картинка</th>
<th>Название статьи</th>
<th>Информация</th>
<th>Ссылка</th>
</tr>
';
$data = file('base.txt');
foreach($data as $line)
{
list ($pic, $sname, $info, $link) = explode(";;",$line);
echo '<tr><td><img src="'.$pic.'"></td><td>'.$sname.'</td><td>'.$info.'</td><td><a href="'.$link.'">'.$link.'</a></td></tr>';
}
echo '</table>';
}
?>
Соответственно для добавления пишешь script.php?add, а для отображения ?show
|
|
|