here I get Student id get correct format but their status i got last value only my java bean code
String[] arr1=new String[1000]; //stuid
if(aa!=null)
{
arr1=aa.split(",");
}
String[] arr = new String[1000]; //status
if(ss!=null){
arr = ss.split(",");
}
for(int j=0;j<arr1.length;j++)
{
for(int i=0;i<arr.length;i++)
{
bb.setStuid(arr1[j]);
bb.setStatus(arr[i]);
bb.setSid(sid);
bb.setCid(cid);
bb.setTtid(ttid);
bb.setDate(date);
bb.setDid(did);
bb.setHour(hour);
}
bb=ad.AddAttendance(bb);
}
return bb;
}
see my images
and my mysql inserted value is result page in mysql database (wrong value)
But, what I want exactly correct data show in front end
You are always looping the entire arr
array for each of the arr1
element. And that's why for each stuid, status is the last value (since the last value is stored inside bb.setStatus()
when the inner loop completes for one studId).
You have to use single loop. And I think you will get your desired result.
String[] arr1=new String[1000]; //stuid
if(aa!=null)
{
arr1=aa.split(",");
}
String[] arr = new String[1000]; //status
if(ss!=null){
arr = ss.split(",");
}
for(int j=0;j<arr1.length;j++)
{
bb.setStuid(arr1[j]);
bb.setStatus(arr[j]); // It will take status of j'th studId
bb.setSid(sid);
bb.setCid(cid);
bb.setTtid(ttid);
bb.setDate(date);
bb.setDid(did);
bb.setHour(hour);
}
bb=ad.AddAttendance(bb);
}
return bb;
}
Hope this will help.