Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL query
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL query

 Post Reply Post Reply Page  12>
Author
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post 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
%>

 

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post Posted: 20 July 2003 at 4:21pm
That way works too...thank you!
Back to Top
jrockfl View Drop Down
Newbie
Newbie


Joined: 03 February 2003
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrockfl Quote  Post ReplyReply Direct Link To This Post Posted: 20 July 2003 at 4:29pm
How would I use Response.Write? I keep getting errors when I do it
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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>")

Cristian Banu
Soft 4 web
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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%"".
Cristian Banu
Soft 4 web
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.