Click to See Complete Forum and Search --> : loop query


leeny
02-07-2005, 08:52 PM
i have a tacky prob. after doin a loop, im sup to allow the user to check certain columns(those necessary for their search). but how do i know which columns are checked since i did a loop?

here's my codes in case you dun understand



If Request("Submit")="Submit" then

v = request.form("value")
ex = request.form ("exp")
unit = request.form("unit")

sql1 = "Select * from ABS where item = '" &i& "'AND unit = '" &unit& "'"
Set Rs1 = Server.CreateObject("ADODB.RecordSet")
Rs1.open sql1,conn
If Rs1.eof then
Response.write "No records found,please try again!!!"

Else
if ex = "greater or equals to" then

sqlC = "Select Item, Grade, GradeName from ABSSubGrade where Grade >= " &v& " AND ABSID = "&rs1("ABSID")&" "

elseif ex = "Equals to" then
sqlC = "Select Item, Grade, GradeName from ABSSubGrade where Grade = " &v& " AND ABSID = "&rs1("ABSID")&" "

else
sqlC = "Select Item, Grade, GradeName from ABSSubGrade where Grade <= " &v& " AND ABSID = "&rs1("ABSID")&" "

end if

Set RSC = Server.CreateObject("ADODB.RecordSet")
RSC.open sqlC,conn

if ex = "greater or equals to" then
sql3 = "Select Count(*) as ct from ABSSubGrade where Grade >= " &v& " AND ABSID = "&rs1("ABSID")&""

elseif ex = "Equals to" then
sql3 = "Select Count(*) as ct from ABSSubGrade where Grade = " &v& " AND ABSID = "&rs1("ABSID")&""

else
sql3 = "Select Count(*) as ct from ABSSubGrade where Grade <= " &v& " AND ABSID = "&rs1("ABSID")&""
end if

Set RS3 = Server.CreateObject("ADODB.RecordSet")
RS3.open sql3,conn

%>
<br>
<br>
<table width="550" border="1" cellpadding="7" cellspacing="1">
<tr>
<td colspan="2" class="small"><font color="#000000" size="4">Mo<font face="Arial, Helvetica, sans-serif">dified
ABS</font></font><font color="#000066" size="3" face="Arial, Helvetica, sans-serif"><strong>
</strong></font></td>
</tr>
<tr>
<td width="213" class="small"><%=i%></td>
<%
rwset=1
ct=1
Do while not rsc.eof
%>
<td width="300" class="small"><font color="#000000">
<div align="center"> <u><strong><%=RSC("GradeName")%></strong></u>
<input name="option" type="checkbox" id="option" value="checkbox">
</div>
<table width="101" border="1" cellspacing="0" cellpadding="4">
<tr>
<td width="89" height="46"><div align="center"><%=RSC("item")%> </div></td>
</tr>
<tr>
<td width="89" height="56"><div align="center"><%=RSC("Grade")%> </div></td>
</tr>
</table>
<%
f=rwset mod (ct+1)
if(f=0) then
%>
</font> <font color="#000000">&nbsp; </font> </td>
</tr>
<%
end if
ct=ct+1
rwset=rwset+1

rsc.movenext
loop
end if
%>
</table>
<br>
<br>
<input type="submit" name="Submit2" value="Submit">


please assist me

lmf232s
02-07-2005, 09:40 PM
well 1 thing you could do is give the text box the value of the Key_ID/Primary Field of the table you are reading.
Then when you have to refer to what record was selected you will
have the Key_ID/Primary Key Field of the record you need and will
then be able to manuplite that record.


Do while not rsc.eof
%>
<td width="300" class="small"><font color="#000000">
<div align="center"> <u><strong><%=RSC("GradeName")%></strong></u>
<input name="option" type="checkbox" id="option" value="<%=RSC("KEY_ID/PRIMARYKEY")%>">
</div>

leeny
02-15-2005, 01:32 AM
is it possible to place two values (hidden ones) in a checkbox? say for example i need the Primary Key and maybe name?

secondly, if i will to check 2 columns, the return value will be 6,7 right? this way, i have to run my sql query twice right? how do i do that? using counter? is there a way? is this comprehensive? please assist me