Pessoal, preciso de uma ajuda!!!
Estou montando uma tela para atualização dos dados cadastrais dos usuários, esta tela faz um select e traz os valores dentro dos campos para serem atualizados, sem precisar entrar e outra tela para fazer a atualização. Para cada linha (usuário) existe um checkbox com o id de cada um.
Minha dúvida é o seguinte:
Quero atualizar nome e endereço dos usuários com o checkbox selecionado.
Pergunta: Como pegar os valores dos campos nome e endereço de cada usuário selecionado para atualizar no banco.
Ex:
Id nome endereço
1 João xxx
2 Maria yyy
Seleciono os dois checkbox e mando atualizar, quero que o sistema identifique os campos de cada id e atualize no banco.
Alguém pode me ajudar, como fazer isso?
Esse é o meu código que monta a tabela:
<%
if(session.getValue("login_portal") != null){
%>
<%@ page contentType="text/html; charset=iso-8859-1" session="true" import="util.*" language="java" import="java.sql.*" import="java.util.*" import="java.util.Date" import="java.text.SimpleDateFormat" errorPage="" %>
<%
String nomeSession = (String) session.getValue("nomeSession");
//out.println(session.getValue("nomeSession"));
new Conexao();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<!--<META HTTP-EQUIV="Refresh" CONTENT="60;"> -->
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Your description goes here" />
<meta name="keywords" content="your,keywords,goes,here" />
<meta name="author" content="Design: Marcos Scopel" />
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0)" />
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0)" />
<link rel="stylesheet" type="text/css" media="screen,projection" href="../css/style_screen.css" />
<title>Portal das Tecnologias</title>
</head>
<body>
<div class="page-container-1">
<!-- Buffer before header -->
<div class="bufferPOS">
<!-- USUÁRIOS CADASTRADOS -->
<%
int limit = 30; // quantidade de resultados por página
//obtém a quantidade de registros
ResultSet rs_c = Conexao.stm.executeQuery("SELECT COUNT(*) AS c FROM usuarios order by nome_usuario");
rs_c.next();
int total_rows = Integer.parseInt(rs_c.getString("c"));
String pagina = request.getParameter("pagina"); // página atual
if(pagina == null){
pagina = "1";
}
//ponho o número de registros total, o tamanho de página e a página que se mostra
out.println("Found "+total_rows+ " CQA(s)."+"<br>");
if (total_rows == 0){
out.println("Nenhum registro encontrado <br><br>");
}
int limitValue = (Integer.parseInt(pagina) * limit) - limit;
int anterior;
if(Integer.parseInt(pagina) != 1){
anterior = Integer.parseInt(pagina) - 1;
out.println("<a href=?pagina=" + anterior + ">Previous</a>");
}
else
out.println(" Previous ");
int numOfPages = total_rows / limit;
int i;
for(i = 1; i <= numOfPages; i++){
if(i == Integer.parseInt(pagina)){
out.println("<b>" + i + "</b> ");
}
else{
out.println("<a href=?pagina=" + i + ">" + i + "</a> ");
}
}
if((total_rows % limit) != 0){
if(i == Integer.parseInt(pagina)){
out.println(i + " ");
}
else{
out.println("<a href=?pagina=" + i + ">" + i + "</a> ");
}
}
int proxima;
if((total_rows - (limit * Integer.parseInt(pagina))) > 0){
proxima = Integer.parseInt(pagina) + 1;
out.println("<a href=?pagina=" + proxima + ">Next</a>");
}
else
out.println("Next ");
%>
<form name="usuarios" method="post" action="../CqaAtualizaUsuarios">
<table width="95%" class="tableposres" align="center" cellpadding="1" cellspacing="1">
<tr>
<th colspan="12" style="text-align: center;" valign="middle">Users Added</th>
</tr>
<tr>
<th style="text-align: center;" valign="middle">Id</th>
<th style="text-align: center;" valign="middle">Username</th>
<th style="text-align: center;" valign="middle">Address</th>
</tr>
<%
ResultSet rs2 = Conexao.stm1.executeQuery("SELECT * FROM usuarios order by nome_usuario LIMIT " + limitValue + ", " + limit);
while(rs2.next()){
String id = rs2.getString("id_usuario");
String name = rs2.getString("nome_usuario");
String address = rs2.getString("tech_center");
%>
<tr>
<td class="rowpos" style="text-align: center;" align="center"><INPUT type="checkbox" name="id" value="<%=id%>" /></td>
<td class="rowpos" style="text-align: center;" align="center"><INPUT type="text" name="name" value="<%=name%>" /></td>
<td class="rowpos" style="text-align: center;" align="center"><INPUT type="text" name="address" value="<%=address%>" /></td>
</tr>
<%
}
Conexao.con.close();
%>
</table>
</div>
<div class="footer">
<p>Copyright © 2009 xxxx SA | All Rights Reserved</p>
</div>
</body>
</html>
<%
}
else
{
%>
<%@ include file="../logar.jsp" %>
<%
}
%>
Obrigado
Marcos