PHP博客 联系 聚合 管理  

Blog Stats

随笔档案

文章档案


nuoyan

新闻修改

对应的表 p_newsbase p_newscontent id=nid

//更新 修改原新闻的内容
<?php
if(isset($_POST[into_news])){
   $db->query("UPDATE `p_newsbase` SET `cid`='$_POST[cid]', `title`='$_POST[title]', `author`='$_POST[author] 'where id='$_GET[id]'");
    $db->query("UPDATE `p_newscontent` SET content='$_POST[content]',`keyword`='$_POST[keyword]' where nid='$_GET[id]'");
 //UPDATE `p_newsbase` SET `cid` = '$_POST[cid]', `title` = '$_POST[title]', `author` = '任务企鹅w' WHERE `p_newsbase`.`id` = 5 LIMIT 1;
 $db->Get_admin_msg("admin_news_add.php","添加成功");//提示成功并返回编辑页面
//列出新闻内容 先验证是否得到id 然后进行复合查询 获得p_newsbase p_newscontent的新闻
if(!empty($_GET[id])){
   $query=$db->findall("p_newsbase as a,p_newscontent as b where a.id=b.nid and a.id='$_GET[id]'");
    $row_news=$db->fetch_array($query){

  }
}


?>


<table>
 <form action="" method="post" onSubmit="syncTextarea()" >
    <!--这是注意onsubmit//-->
<select name="cid">
<?php
$query=$db->findall("p_newsclass where f_id=0");
     while($row=$db->fetch_array($query)){
        $selected=$row[id]==$row_news[cid]?"selected":NULL;       //selected为选择框 选中状态
      echo "<option value=\"$row[id]\" $selected>$row[name]</option>";
          $query_son=$db->findall("p_newsclass where f_id='$row[id]'");
          while($row_son=$db->fetch_array($query_son)){
                 $selected=$row_son[id]==$row_news[cid]?"selected":NULL;
             echo "<option value=\"$row_son[id]\" $selected>&nbsp;&nbsp;&nbsp;┗$row_son[name]</option>";
  }
}

?>
</select>
<tr>
<td>新闻标题</td>
<td><input type="text" name="title" size="50" value="<?php echo $row_news[title]?>"></td>
</tr>
<tr>
<td>新闻作者</td>
<td><input type="text" name="author" size="50" value="<?php echo $row_news[author]?>"></td>
</tr>
<tr>
<td>关键词</td>
<td><input type="text" name="keyword" size="50" value="<?php echo $row_news[keyword]?>"></td>
</tr>
<tr>
 <td><!--这是一个js编辑器//-->
        <textarea id="edited" name="content" style="width:95%;height:280px;"><?php echo $row_news[content]?></textarea>
        <!--id很重要 给编辑器使用//-->
        <script language="javascript" type="text/javascript" src="edit/whizzywig.js"></script>
        <!--引用编辑器//-->
        <script type="text/javascript">buttonPath = "edit/images/";makeWhizzyWig("edited", "all");</script></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="into_news" value="添加新闻" size="20"></td>
</tr>
</form>
</table>

 

posted on 2010-01-13 10:15 nuoyan 阅读(486) 评论(0)  编辑 收藏 引用 网摘

只有注册用户登录后才能发表评论。
网站导航: