台灣最大程式設計社群網站
∣
免費加入會員
∣登入
∣回首頁∣
您好
線上人數
1856
會員總數:
246319
討論主題:
189850
討論區
程式下載/上傳
科技新聞
專欄文章
會員中心
加值服務
外包接案
求職求才
登入
登出
歡迎您
免費
加入會員
討論區選單
新手必讀
我要提問!!
討論區
個人討論區
我的關注主題
我的黑名單
討論區EP英雄榜
專家等級說明
討論區常見問題
兌換發問點數QP
扣點申請加值服務
申請版主
開發工具
ASP
ASP.NET
C#
VB.NET
VB6
C/C++
PHP
Java
Java Script/ Node.js
AJAX / JSON / jQuery
其他語言
行動裝置開發
Android APP 開發
iOS APP/ swift 開發
Windows Phone APP
資料庫
ACCESS
MS SQL
MySQL
Oracle
其他DB
多媒體 / 網管
CSS/HTML5/Bootstarp
影像處理
office VBA / WinOS
Windows 伺服器
Linux / Unix
網管 / 資安 / VM
硬體 / 週邊 / 其他
綜合
求職求才
外包接案
心情甘苦談
網站經營 / 合夥 / 證照
建言 / 公告
文章區
專欄文章
科技新聞
Blog精華文章
討論區列表
>>
Java
>> JSP SQL 如何一次更新多筆資料
[]
[
我要回覆
]
1
JSP SQL 如何一次更新多筆資料
價值 : 30 QP
點閱數:742 回應數:1
樓主
黑~~
0
21
606
47
發送站內信
大家好:
我要做一個修改頁面
USER可選定他要修改的資料,並更改
我勾了3筆資料,但永遠只能修改第一筆.....
要如何才能一次3筆都修改到
以下是程式碼:
<%@ include file = "db.jsp"%> //已經連結資料庫 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <% int i; String[] a =request.getParameterValues("a"); String name2 = request.getParameter("name"); String code2 = request.getParameter("code"); String youad22 = request.getParameter("youad"); String c_id2 = request.getParameter("c_id"); if( request.getParameter("fix") != null ){ String sql = "update send set youad = '" + youad22 + "',name = '" + name2 + "',code = '" + code2 + "' where c_id ='" + c_id2 + "' "; int b = stmt.executeUpdate(sql); } %> <form action = "update.jsp" method = "post"> <% if(request.getParameter("update") != null && a!=null) { for(i=0;i<a.length;i++){ String sql="select * from send where c_id = '" + a[i] + "' "; ResultSet rs = stmt.executeQuery(sql); while(rs.next()){ %> 客戶代號 : <input type = "text" name= "c_id" size = "15" value = "<%=a[i]%>"> 客戶名稱 : <input type = "text" name= "name" size = "15" value = "<%=rs.getString("name")%>"> 郵遞區號 :<input type = "text" name= "code" size = "10" value = "<%=rs.getString("code")%>"> 客戶地址:<input type = "text" name= "youad" size = "35" value = "<%=rs.getString("youad")%>"> <input type = "submit" name = "fix" value = "fix"> <% } }}%> </form> <form action = "update.jsp" method = "post"> <table border="1"><tr><th>選項</th><th>客戶代號</th><th>客戶名稱</th><th>郵遞區號</th><th>客戶地址</th></tr> <% String sql = "select * from send"; ResultSet rs = stmt.executeQuery(sql); while(rs.next()){ String youad = rs.getString("youad"); String youad2 = rs.getString("youad2"); String name = rs.getString("name"); String c_id = rs.getString("c_id"); String code = rs.getString("code"); out.print("<tr><td>"+"<input type=checkbox name='a' value="+c_id+">"+"</td><td>"+ c_id + "</td><td>"+name+"</td><td> "+ code+"</td><td> " + youad+ youad2+ "</td></tr> "); } rs.close(); %> </table> <input type = "submit" name = "update" value = "update"> </form> </body> </html> </html>
thanks
搜尋相關Tags的文章:
[ JSP ] ,
[ sql ] ,
本篇文章發表於2018-09-27 09:29
1樓
作者回應
黑~~
以解決
本篇文章回覆於2018-09-27 11:27
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
1
回覆
如要回應,請先
登入
.
|
網站導覽
|
網站介紹
|
4P點數說明
|
電子報
|
小舖活動
|
大事紀
|
廣告刊登
|
常見問題
|
聯絡我們
|
版權所有 ©copyright 2000 All Rights Reserved