CHECKBOX DYNAMIQUE  Aéronautique  Astronomie  Géologie  Météorologie  Végétaux
 Animaux  Biologie Santé  Informatique  Paléontologie  
 Archéologie  Chimie  Mathématiques  Physique  
<%
Dim p
p=0
Set statRes = SQLQuery(adoCon, "SELECT * From ANO_status WHERE status_id > 0 ORDER BY status_id ASC")
If Not statRes.EOF Then
Do While Not statRes.EOF
%>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<% = statRes("sname")%>
</font>
<input type="checkbox" name="<%response.write("status"&p)%>" value="<% = statRes("status_id")%>"> <br>
<%
p=p+1
statRes.MoveNext
Loop
End If
statRes.Close
%>
Resultat du script précédent
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
OUVERT
</font>
<input type="checkbox" name="status1" value="1"> <br>

<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
EN ATTENTE
</font>
<input type="checkbox" name="status2" value="2"> <br>

<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
CORRIGE
</font>
<input type="checkbox" name="status3" value="3"> <br>

<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
ABANDONNE
</font>
<input type="checkbox" name="status4" value="4"> <br>

<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
FERME
</font>
<input type="checkbox" name="status5" value="100"> <br>
2 EME PAGE QUI RECUPERE LES DONNEES

<%
p=0
tour = Request.form("form_p")

Dim status()
For p = 0 to tour
Redim Preserve status(p+1)
status(p) = Request.Form("status" & p)
Next

%>

POUR LA REQUETTE

Dim m
m=0
For p=0 to tour
if status(p)>0 and m=0 then
whereStr = whereStr & "AND("
m=m+1
end if
NEXT

 

La construction de la parenthèse

dim n
n=0
For p=0 to tour
If status(p) <> 0 Then
    If status(p) > 0 Then
      whereStr = whereStr & "p.status= "& status(p)&"OR "
   Else
   whereStr = whereStr & " AND p.status<>" & Cfg(adoCon, "CloseStatus")
   End If
End if
NEXT

if Mid (whereStr , Len(whereStr)-2,3) = "OR " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -3)
end if

La construction de la requette.

Ce sont des OR qui s'ajoute à chaque tour.

Le dernier OR doit être effacé

Mid : Renvoir un nombre de caractères dans une chaîne à partir de la position spécifiée.

Je prend la chaîne whereStr de 1 jusqu'à son nombre de caractère et j'enlève 3.
J'ai donc ma chaîne avec trois caractère en moins.

Uniquement si la chaîne se termine par OR

Dim q
q=0
for p=0 to tour
if status(p)>0 and q= 0 then
whereStr = whereStr & ")"
q=q+1
end if
next
La construction de la dernière parenthèse
RESULTAT de la requette pour cette partie

En fonction de ce qui a été coché

AND(p.status= 1 OR p.status= 2 OR p.status= 3 OR p.status= 4 OR p.status= 100)
AND(p.status= 1)
AND(p.status= 1 OR p.status= 100)

Hit-Parade