Просмотр файла razdel.php

Размер файла: 1.52Kb
  1. <?php
  2. include 'inc/db.php';
  3. include 'inc/1.php';
  4. if (!$_GET['id'])header("Location: /forum.php");
  5. $id=intval($_GET['id']);
  6. $a=mysql_query("SELECT * FROM `forum_t` WHERE `razdel` = '$id'");
  7. if ($_GET['edit'] && ($user['admin']==1)){
  8. if (!$_POST['eok']){
  9. $n=mysql_query("SELECT * FROM `forum_t` WHERE `id` = '$id'");
  10. $e=mysql_fetch_assoc($n);
  11. echo "<form action='?edit=1&id=$id' method='POST'>Имя:<br><input type='text' name='ename' value='".htmlspecialchars($e['name'])."'><br>Описание:<br><textarea name='emsg'>".htmlspecialchars($e['opis'])."</textarea><br><input type='submit' name='eok' value='Изменить'></form>";
  12. include_once 'inc/foot.php';
  13. exit;
  14. }
  15. elseif ($_POST['eok'] && $_POST['ename'])
  16. {
  17. $name=mysql_escape_string($_POST['ename']);
  18. $msg=mysql_escape_string($_POST['emsg']);
  19. mysql_query("UPDATE `forum_t` SET `name` = '$name', `opis` = '$msg' WHERE `id` = '$id'");
  20. echo "<div class='msg'>Изменено</div>";
  21. }
  22. }
  23. if (mysql_num_rows($a)==0)echo("Раздел пустой<br>");
  24. $b=1;
  25. while ($f=mysql_fetch_assoc($a)){
  26. $o=($b%2);
  27. $count=mysql_num_rows(mysql_query("SELECT * FROM `forum` WHERE `razdel` = '$f[id]'"));
  28. echo "<div class='p$o'><img src='icon/podforum.gif'> <a href='rf.php?id=$f[id]'>".htmlspecialchars($f['name'])."</a> ($count)<br>".htmlspecialchars($f['opis'])."</div>";
  29. $b++;
  30. $count=0;
  31. }
  32. if ($user['admin']==1)echo "<a href='newr.php?id=$id'>Новый подфорум</a> | <a href='?edit=1&id=$id'>Изменить текущий</a>";
  33. include_once 'inc/foot.php';
  34. ?>
  35.  
  36.  
  37.