如何在php中通过单击链接更新表

如何在php中通过单击链接更新表,php,mysql,href,Php,Mysql,Href,我有一个项目,我为学生创建了一个计分系统。学生可以查看一个问题的答案,但如果他们这样做,他们将失去2分,并且他们的档案也应更新为新的分数。是否可以通过单击链接来更新表?我尝试执行以下操作: if($points >0) { if(($status== '') || ($newuniq_id!= $uniq_id) || ($newquestion_id!= $quid)) { $query = "insert into status(uniq_id,

我有一个项目,我为学生创建了一个计分系统。学生可以查看一个问题的答案,但如果他们这样做,他们将失去2分,并且他们的档案也应更新为新的分数。是否可以通过单击链接来更新表?我尝试执行以下操作:

if($points >0)
{
    if(($status== '') || ($newuniq_id!= $uniq_id) || ($newquestion_id!= $quid))
    {   
        $query = "insert into status(uniq_id, user_id, user_name, question_id, status) values('$uniq_id', '$id','$name','$quid','read')";
        mysql_query($query);

        $newpoints = $points - $cut_points;
        $newquery1 = "update $tabl_u set points = '$newpoints' where uniq = '$uniq1'";
        $newquer2 = mysql_query($newquery1);
    }
}

假设您的php脚本是myscript.php

您可以使用要更新的项的uniqid创建引用脚本的每个链接

<a href="myscript.php?update=true&uniqid=<?=$uniqid?>" />

您可能想查看一些PHP文档,因为mysql函数集已经贬值。为了解决您的问题,我会使用标准的“a href”链接请求返回到同一页面,该链接将在URL中包含您的数据,或者如果您不希望您的用户看到URL中的数据,请使用$\u POST

http://www.php.net/manual/en/function.mysql-query.php

mysqli_*可供使用。

wow…如果你不知道答案..就投票否决问题(事实上,我投了反对票,因为你的问题中没有大写字母和标点符号。好吧……可能是吧,我尽可能地澄清它……)
http://www.php.net/manual/en/function.mysql-query.php