gpt4 book ai didi

php - MySQL 中对空表的正确查询是什么?

转载 作者:行者123 更新时间:2023-11-29 21:22:17 25 4
gpt4 key购买 nike

这是我关于尝试清空表格的代码,但每次我使用名为 delete 的按钮时它都不起作用。有谁知道此查询的正确方法是什么?请帮忙,提前致谢。

if (isset($_POST['delete'])) {
$EmptyQuery = mysql_query("TRUNCATE TABLE `tblresult`", $connect);
};

<form id="NewEvaluation" method=post action=setnewevaluation.php onsubmit="return confirm('Are you sure you want to set a new evaluation? this will empty all the table for results,evaluate,answers and finalresults.');">
<input type="image" name='delete' id=confirm src="Confirmdean.jpg"/>
</form>

最佳答案

事情在这里:

<input type="image" name='delete' id=confirm src="Confirmdean.jpg"/>

作为提交的图像类型不会处理 POST 指令。

您需要使用实际的提交类型输入。

<input type='submit' name='delete' value='DELETE'>

或作为使用提交类型的按钮:

<button type='submit' name='delete'>DELETE</button>

这就是为什么您的代码没有“触发”条件语句内的任何内容,也没有根据您的查询检查错误,我已经在评论中说过两次了。

$EmptyQuery = mysql_query("TRUNCATE TABLE `tblresult`", $connect) or die(mysql_error());

关于php - MySQL 中对空表的正确查询是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35665108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com