[RESOLVED] how to display data from database in a set of 3
now here is my problem
i want to know dat how will u display da data from sql database in a set of 3 in one row..
wenever u run a query every entry is displayed in a new row, i want to know dat how will u display da 1st 3 in a single row and ofcourse seperated in 3 columns and den next 3 in 2nd row.
also how will u alternate colors of dese rows, i hav done it in single row but how will u apply da same color in 3 coloumns (same row; where 3 fields are being displayed)
ofcourse u cannot do...dere might be a logic or something like dat..which can divide da records into da set of 3...i.e first 3 records will be shown in 1st row and den next 3 in another row...and just like dat till da end of records...
also i wud like to mention if dere are 100 records den i only want to display da first tweleve...in a set of 3....in each row....hence dere will be altogether 4 rows.....
I think i know what you after. I dont think this code will work and it will need to be applied differently but i just wanted to toss something up really quick to give you an idea. It sounds like if your query returned 12 records. You would display the first 3 in a row then the next 3 in another row, eventually you would end up w/ 4 rows and have 3 records in each row.
You just need to loop the records and find when you have looped 3 times, meaning that you have 3 records in that row. Then end the row, start a new row and do it over again.
or search this forum as this has been asked many times and the answers are always the same but some very to a degree. They all work, its just which method will suit your needs.
Hope this helps.
Code:
sSLQ = "SELECT * FROM TABLE"
If Not oRS1.EOF then
'Create your table header
i = 0
Do While Not oRS1.EOF
If i Mod 3 Then
Response.write "<tr>"
End If
Response.write "<td>" & oRS1("Record") & "</td>
If i Mod 3 Then
Response.write "</tr>'
End If
i = i + 1
oRS1.MoveNext
Loop
now after i have done dis....i want to display da records from da second entry from da table...
i.e i dont want da first record to be displayed
e.g if da first record is Afghanistan and da second record Albania, den da records shoud start to be displayed from Albania and den till da end of records.
Not quite sure what you after here. Will Afghanistan all ways be the first record?
If so just find if
Code:
Do While Not RS.EOF
If Rs("localname") <> "Afghanistan" Then
'Exexcute your code
Else
'Do nothing because its Afghanistan this time, move to the next record
End if
RS.MoveNext
Loop
Im not that fond of that example because you are hard coding a string name into you logic.
Bookmarks