2012-01-19 51 views
0

我在表中有幾條記錄。如果我想確保連續只有3列,無論記錄的數量如何。HTML中的斷點表

我已經使用了以下內容。但問題是我在記錄1中有多個記錄。

以下是結果,但我希望它成爲第二個例子。

0378    0378 
Ms. Mary Jane   Ms. Jane Smith   
SCHOOL (SCIENCE)    SCHOOL (SCIENCE) 
CLASS: Class1   CLASS: Class2 
BUNDLE: 1     BUNDLE: 2 

ABC: 41    FGH: 1 
         FGH: 1 


JKL: 2    0378 
         Mr. David O'Conner 
         SCHOOL (SCIENCE) 
         CLASS: Class3 
         BUNDLE: 3 

         ORE: 42 

第2個例子,其中JKL仍在第1行。

0378    0378 
Ms. Mary Jane   Ms. Jane Smith   
SCHOOL (SCIENCE)    SCHOOL (SCIENCE) 
CLASS: Class1   CLASS: Class2 
BUNDLE: 1     BUNDLE: 2 

ABC: 41    FGH: 1 
         FGH: 1 
         JKL: 2 

0378 
Mr. David O'Conner 
SCHOOL (SCIENCE) 
CLASS: Class3 
ISSUE: 01-2012 ISSUE 
BUNDLE: 3 

ORE: 42 

回答

3

您需要使用模運算符:

Response.Write "<table width=""100%"">" 
r = 0 
Do Until objRS.EOF 
    myData = objRS("myfield") 
    If (r Mod 3)=0 Then 
     If r>0 Then 
      Response.Write "</tr>" 
     End If 
     Response.Write "<tr width= ""354"">" 
    End If 
    Response.Write "<td>" & myData & "</td>" 
    r = r + 1 
    objRS.MoveNext 
Loop 
objRS.Close 
If r>0 Then 
    Response.Write "</tr>" 
End If 
Response.Write "</table>" 

這將顯示三列數據。

+0

由於r等於一條記錄,我試着將兩個或多個記錄組合在一起。它會在第3條記錄中突破,但是我希望當有三個類別而不是三個產品時它會突破 – JohnDoe4136

+0

對不起,不知道你的意思。有例子嗎? –

+0

我已經更改了上面的代碼。第三條記錄後,它將打破下一行。但是我有兩個或兩個以上的記錄成爲一個「主要」記錄。我想連續3個「主要」記錄。 – JohnDoe4136

0

不知道柱diferentiates記錄,但我認爲你正在尋找的東西是這樣的:

response.write"<table width=""100%"">" 
    response.write"<tr width= ""354"">" 

    response.write"<td>" 
     response.write"<table>" 
     for i= 1 to [flag to stop column1] 
     response.write"<tr>" 
     response.write"<td>"  
     response.write"Record" & i & ":" & record(i) 
     response.write"</td>" 
     response.write"</tr>" 
     next 
     response.write"</table>" 
    response.write"</td>" 

    response.write"<td>" 
     response.write"<table>" 
     for i= 1 to [flag to stop column2] 
     response.write"<tr>" 
     response.write"<td>"  
     response.write"Record" & i & ":" & record(i) 
     response.write"</td>" 
     response.write"</tr>" 
     next 
     response.write"</table>" 
    response.write"</td>" 

    response.write"<td>" 
     response.write"<table>" 
     for i= 1 to [flag to stop column3] 
     response.write"<tr>" 
     response.write"<td>"  
     response.write"Record" & i & ":" & record(i) 
     response.write"</td>" 
     response.write"</tr>" 
     next 
     response.write"</table>" 
    response.write"</td>" 

    response.write"</tr>" 
    response.write"</table>"