在我的项目中,我想使用选择框将日期分别读取为日、月、年。使用的代码是
<%
String value=null;
String[] h=null;
h=request.getParameterValues("qns[]");
String expert=request.getParameter("expert");
int sday=Integer.parseInt(request.getParameter("sday"));
int smonth=Integer.parseInt(request.getParameter("smonth"));
int syear=Integer.parseInt(request.getParameter("syear"));
int eday=Integer.parseInt(request.getParameter("eday"));
int emonth=Integer.parseInt(request.getParameter("emonth"));
int eyear=Integer.parseInt(request.getParameter("eyear"));
String start=syear+"-"+smonth+"-"+sday;
String end=eyear+"-"+emonth+"-"+eday;
for(int i=0;i<h.length;i++)
{
s.savetask(h[1],expert,start,end);
}
%>
保存任务功能是
public int savetask(String qnid,String userid,String start,String end)
{
int n=0;
try{
String sql="insert into task(user_id,question_id,start_date,end_date,status)values('"+qnid+"','"+userid+"','"+start+"','"+end+"',0";
n = db.modifyingQueries(sql);
}
catch(Exception e){
}
return n;
}
但它不是向表中插入值task
任务的表格式是
task_id int (Auto increment)
user_id int
question_id int
start_date date
end_date date
status int