为什么这段代码不会更新数据

时间:2015-02-19 21:39:17

标签: php mysql

我无法更新此代码的数据。它只是返回主页而没有任何更新。我确定连接文件上的连接数据。 并且数据库中的所有列都是正确的  请问有什么问题

        <?
include "../include/config.php";


echo "<a href='del_update.php'>Delete</a>"
?>

        <div class="articleall">


<?

    $id = $_REQUEST['do'];
    if($_REQUEST['do'] == 'remove'){
        $gid= $_GET['id'] ;
        $de = mysql_query("delete from article where id='$gid'");

        if($de){
            echo "Delete doen";
            echo '<meta http-equiv="refresh" content="2; url=del_update.php"/>';
            exit ;
            }


        }
        #############################################

        if($_REQUEST['do'] == 'update'){
            $gid2 = $_GET['id'];
            $sel = mysql_query("select * from article where id='$gid2'");
            $row2 = mysql_fetch_assoc($sel);        
            $id2 =$row2['id'];
            $name2= $row2['name'];
            $auther2= $row2['auther'];
            $text2 = $row2['text'];


            ####################################### post

            $postid = $_POST['id'];
            $postname = $_POST['name'];
            $postauther = $_POST['auther'];
            $posttext = $_POST['text'];
            if($_POST['del_update']){
                if($postname ==''){
                    echo "it is empty";
                    echo '<meta http-equiv="refresh" content="2; url=del_update.php"/>';
                     exit ;
                        }
                     else {
                         $update = mysql_query("update article set

                        name ='$postname',
                        auther='$postauther'
                        where id ='$postid'
                        ");
                         if(isset($update)){
                    echo "update done ";
                    echo '<meta http-equiv="refresh" content="2; url=del_update.php"/>';
                     exit ;

                         }
                     }

                }








    ?>
<form action="del_update.php?do=update" method="post" >


  title : <input type="text" class="name" name="name" value="<?=$name2; ?>"></br>
  auther : <input type="text" class="name" name="auther" value="<?=$auther2;?>"></br>

  date : <input type="text" class="name" name="date" value=""></br>
            <input type="hidden" class="name" name="id" value=""></br>
      text :          <textarea value="" id="elm1" name="elm1"  rows="15" cols="80" style="width: 80%">
                        <? echo $text2; ?>
                    </textarea>
  <input type="submit" class="botton" value="update" name="go"><br>

</form> 



<?

}

?>




<?

                $query = mysql_query("select * from article order by id desc  ");

                while ($row = mysql_fetch_assoc($query)

                    ){
                    $id = $row['id'];
                    $name = $row['name'];



                echo "



                    <div class='shortarticle'>
                                <h3>$name || 
                                <a href='?do=remove&id=$id'>Delete</a>|| 
                                <a href='?do=update&id=$id'>Update</a>
                                </h3>



                        </div>




                </div> ";
}

?>

0 个答案:

没有答案