PHP未在SQL数据库中更新数据


Data not updating in SQL databse by PHP

我是编码新手,我正在尝试通过Php更新数据库中的数据。我正在努力更新数据,但我不知道问题出在哪里,也没有错误。我的第一个文件是

"ppp.html"
<html>
<form action="l.php"method="post">
<input type ="text" name ="complaint">
</input>
<input type="submit"></input>
</html>

现在我的"L.php"它也没有显示任何错误。它很容易通过

<?php
        $complaint="";
        if(    
       isset($_POST['complaint']))
       {$complaint =$_POST['complaint'];}
mysql_connect("localhost","root","") or die ("couldnt attack ");
mysql_select_db("site")or die('i surrender');
$query=("SELECT * FROM site2 where category='$complaint'") or die("couldnt select");
$result=mysql_query($query) or die ('hghyt');
while ($complaint= mysql_fetch_array($result))
{

              echo"<td>".'<br>'.$complaint['category']."</tr>";
              ECHO"<TR>"."<A HREF='update.php'>"."UPDATE"."</A>";

             echo "<br/>";
             ECHO"</table>";

    }        
    ?>

很抱歉有非常错误的查询和非常不合适的编码方式,但我正在通过互联网自学现在我的"update.php文件"

<html>
<form action="update1.php" method="post">
<input type= "text" name="blue"></input>
<input type= "submit"></input>
</form>
</html>

它也以简单的方式进行,并且没有显示任何问题,现在我的最后一个文件"update1.php"

<?php
$complaint="";
 if(isset ($_POST['complaint']))
 {$complaint =$_POST['complaint'];}
$blue="";
 if(isset ($_POST['blue']))
 {$blue =$_POST['blue'];}
mysql_connect("localhost","root","") or die ("couldnyt coibnovdbs");
mysql_select_db("site") or die ("no databse");
$query=("update site2 set category='$blue' where category ='$complaint'") or die ("couldnt attack");
$result=mysql_query($query) or die("kjkk");
?>

请帮帮我。它困扰着我,我找不到任何解决方案。我认为问题只在最后一个文件中,但没有显示任何错误。

感谢

考虑到您网站的流量,update1.php从未收到$complaint中的值,因此无法更新。您需要将值传递给它。

例如,以下编辑就足够了。

编辑L.php

echo"<td>".'<br>'.$complaint['category']."</tr>";
ECHO"<TR>"."<A HREF='update.php?complaint=".$complaint['category']."'>"."UPDATE"."</A>";

编辑更新.php

<html>
<form action="update1.php" method="post">
<input type="hidden" name="complaint" value="<?php echo $_GET['complaint'] ?>"
<input type= "text" name="blue"></input>
<input type= "submit"></input>
</form>
</html>