Advertisement
zero50x

ПР Select

May 7th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php
  2. include_once("db_blog.php");
  3. $res = mysql_query("select `tema_id`, `tema_name` from `tema`"); // выбираем данные для вставеи в select
  4.  
  5. $tid = $_GET['tema_id'];
  6. $id = $_GET['id'];
  7.  
  8. $result = mysql_query(" SELECT id, title, zag, anons, text, date, tema  FROM articles WHERE id='$id'");
  9. $row = mysql_fetch_assoc($result);
  10.  
  11. if (isset($_POST['save']))
  12. {
  13.     $p_text = trim($_POST['p_text']);
  14.     $p_tema = strip_tags(trim($_POST['p_tema']));
  15.    
  16.     mysql_query (" UPDATE news SET text='$p_text', tema='$p_tema' WHERE id='$id' ");
  17. mysql_close();
  18. }
  19. ?>
  20.  
  21. <form method="post" action="edit_art.php?id=<?PHP echo $id;?>">
  22. Текст<br/>
  23. <textarea cols="40" rows="10" name="p_text"><?php echo $row['text']?></textarea><br/>
  24. Тема<br/>
  25. <select name="p_tema" size="1">
  26.        <? while ($row = mysql_fetch_assoc($res)): ?>
  27.        <option value="<?=$row['tema_id'] == $_GET['tema_id']?>"><?=$row['tema_name']?></option>
  28.        <? endwhile;?>
  29. </select><br/><br/>
  30. <input type="submit" name="save" value="Сохранить" />
  31. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement