| Author |
Topic Search Topic Options
|
jrockfl
Newbie
Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
|
Post Options
Thanks(0)
Quote Reply
Topic: SQL query Posted: 20 July 2003 at 8:45am |
What is the syntax so I can add AND status = open to this query? strSQL = "SELECT * FROM tbltickets WHERE userid=" & lngRecordNo
Also, how can I alternate table row colors with this code?
<% 'Loop through the recordset Do While Not rsTickets.EOF %> <tr bgcolor="#D8D8D8"> <td><%=(rsTickets("ticketid"))%></td> <td><%=(rsTickets("ticstat"))%></td> <td><%=(rsTickets("ticpri"))%></td> <td><%=(rsTickets("ticsub"))%></td> <td><%=(rsTickets("opendate"))%></td> </tr> <% 'Move to the next record in the recordset rsTickets.MoveNext Loop %>
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 20 July 2003 at 9:50am |
<% strSQL = "Select * from tblTickets where userid=" & lngRecordNo & " AND status = 'open'" ........ 'Loop through the recordset colcounter = 1 Do While Not rsTickets.EOF if (colcounter MOD 2) then tblbgcol = "bgcolor=""#D8D8D8""" else tblbgcol = "bgcolor=""#D0D0D0""" end if
%> <tr <%=tblbgcol%> <td><%=(rsTickets("ticketid"))%></td> <td><%=(rsTickets("ticstat"))%></td> <td><%=(rsTickets("ticpri"))%></td> <td><%=(rsTickets("ticsub"))%></td> <td><%=(rsTickets("opendate"))%></td> </tr> <% colcounter = colcounter + 1 'Move to the next record in the recordset rsTickets.MoveNext Loop %>
|
Quick and dirty. You should consider to put everything in vbscript and not mix it. Use response.write for your table generation.
Edited by michael
|
|
|
 |
jrockfl
Newbie
Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
|
Post Options
Thanks(0)
Quote Reply
Posted: 20 July 2003 at 12:59pm |
|
Thank you! That would perfectly. I will go back an use response.write. Do you typically use response.write as much as possible for the html?
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 20 July 2003 at 4:06pm |
i do it a little different (less lines of code), not that it really matters
<% strSQL = "Select * from tblTickets where userid=" & lngRecordNo & " AND status = 'open'" ........ rowColor = "#D8D8D8" 'Loop through the recordset Do While Not rsTickets.EOF %> <tr bgcolor="<%= rowColor %>"> <td><%=(rsTickets("ticketid"))%></td> <td><%=(rsTickets("ticstat"))%></td> <td><%=(rsTickets("ticpri"))%></td> <td><%=(rsTickets("ticsub"))%></td> <td><%=(rsTickets("opendate"))%></td> </tr> <% if rowColor = "#D8D8D8" then rowColor = "#FFFFFF" else rowColor = "#D8D8D8" 'Move to the next record in the recordset rsTickets.MoveNext Loop %>
|
|
Contribute to the working anarchy we fondly call the Internet
|
 |
jrockfl
Newbie
Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
|
Post Options
Thanks(0)
Quote Reply
Posted: 20 July 2003 at 4:21pm |
|
That way works too...thank you!
|
 |
jrockfl
Newbie
Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
|
Post Options
Thanks(0)
Quote Reply
Posted: 20 July 2003 at 4:29pm |
|
How would I use Response.Write? I keep getting errors when I do it
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 20 July 2003 at 11:57pm |
Response.Write("<TR>") Response.Write("<TD Width=""10%"" BGCOLOR=""" & rowColor & """><Font Face=""Georgia, Times New Roman, Times, serif"" Color="""">" & RSTickets("ticketID") & "</Font></TD>")
.....
Response.Write("<TD Width=""10%"" BGCOLOR=""" & rowColor & """><Font Face=""Georgia, Times New Roman, Times, serif"" Color="""">" & RSTickets("ticketOpenDate") & "</Font></TD>") Response.Write("</TR>") And right after the end of the loop Response.Write("</Table>")
|
|
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 21 July 2003 at 12:00am |
|
As a rule, in Response.Write statements, the HTML brackets should be between double quotes "<HTML TAG>" and values of the HTML in double double quotes like in width = ""10%"".
|
|
|
 |