gpt4 book ai didi

mysql - 为什么我无法删除用户输入给出的行?

转载 作者:行者123 更新时间:2023-11-29 19:03:27 25 4
gpt4 key购买 nike

   <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>


<!DOCTYPE html>


<html>


<head>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<title>JSP Page</title>


</head>


<body>


<sql:setDataSource var="dbsource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3309/ikart" user="root" password="1311151011"/>

//这些是我的数据库链接代码,希望能帮助您解决我的问题。//

 <sql:update dataSource="${dbsource}" var="count">
DELETE FROM all_product
WHERE id='${param.id}'

//我想通过在框中输入 id 来删除该行//

 </sql:update>

<c:if test="${count>=1}">


<font size="5" color='green'> Congratulations ! Data deleted successfully.

</font>

//用于行删除的警报消息...// 前往更新

    //for go back to update page after the row deleted successfully...............//   


</c:if>


</body>


</html>

最佳答案

我可以确认您的代码工作正常,恭喜!数据删除成功。在我从您的 JSP 中删除注释后,将显示 Go For Update

我已经清理了你的代码:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<sql:setDataSource var="dbsource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3309/ikart" user="root" password="1311151011"/>
<sql:update dataSource="${dbsource}" var="count">
DELETE FROM all_product
WHERE id='${param.id}'
</sql:update>
<c:if test="${count>=1}">
<font size="5" color='green'> Congratulations ! Data deleted successfully. </font>
<a href="UpdateItems.jsp">Go For Update</a>
</c:if>
</body>
</html>

如果不起作用,请告诉我错误消息。

关于mysql - 为什么我无法删除用户输入给出的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43689261/

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