Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - If Then Else statement
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

If Then Else statement

 Post Reply Post Reply
Author
kenn View Drop Down
Newbie
Newbie
Avatar

Joined: 09 September 2002
Location: United Kingdom
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kenn Quote  Post ReplyReply Direct Link To This Post Topic: If Then Else statement
    Posted: 09 September 2003 at 1:11pm

I have a page which displays people who have registered for a particular tender. Which works fine however some tenders have no one registered. Can anyone tell me how i use an IF THEN ELSE Statement ??? to display  a message like 'No one has registered for this tender' if the fields are blank.

Below is the code on the page.

Many thanks

Kenn

<TABLE width="30%" align="center" border="0" cellPadding="2" cellSpacing="0">
<TR>
<TD WIDTH="30%" class="text"><center><%=Session("currentTender")%>&nbsp
;Registrations:<center></TD>
</TR>
</TABLE>
<br>
<TABLE bgcolor="<% = strTableBorderColour %>" WIDTH="75%" ALIGN="center" BORDER="1" CELLPADDING="2" CELLSPACING="0">
<TR ALIGN="center" bgcolor="<% = strTableBorderColour %>">
<TD><center><font face="arial" color="#000000" size="3">First Name</font><center></TD>

<TD><center><font face="arial" color="#000000" size="3">Last Name</font><center></TD>

<TD><center><font face="arial" color="#000000" size="3">Company</font><center></TD>
<TD><center><font face="arial" color="#000000" size="3">Position</font><center></TD>
<TD><center><font face="arial" color="#000000" size="3">Email</font><center></TD>
<TD><center><font face="arial" color="#000000" size="3">Tender</font><center></TD>
</TR>
<%
Dim objLot, SQL, oRS, oConn, SQLstmt
Set conn = server.createobject("adodb.connection")
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("../private/zips.mdb")
conn.Open DSNtemp
SQL = "Select regID, FirstName, LastName, Company, Position, Email, Download From registrations WHERE DownLoad='" & Session("currentTender") & "'"
Set oRS = conn.Execute(SQL)
While Not oRS.EOF
%>
<TR ALIGN="center" bgcolor="<% = strTableBorderColour %>">
<TD><input type="text" name="FirstName" size="12" value="<%=oRS("FirstName")%>"</TD
>
<TD><input type="text" name="LastName" size="12" value="<%=oRS("LastName")%>"</TD
>
<TD><input type="text" name="Company" size="28" value="<%=oRS("Company")%>"</TD
>
<TD><input type="text" name="Position" size="18" value="<%=oRS("Position")%>"</TD
>
<TD><input type="text" name="Email" size="30" value="<%=oRS("Email")%>"</TD
>
<TD><input type="text" name="Download" size="25" value="<%=oRS("Download")%>"</TD
>
</TR>

<%
oRS.MoveNext
Wend
conn.Close
Set conn = nothing
Set SQLstmt = nothing
End If

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: 09 September 2003 at 1:34pm

Assuming that download = tender


<TD><input type="text" name="Download" size="25" value="<%=oRS("Download")%>"</TD>

to

<% mystring = oRS("Download")
      If mystring = "" THEN mystring = "No one has registered for this tender"
%>
<TD><input type="text" name="Download" size="25" value="<%=mystring%>"</TD>       

I hope I understood you right. Not sure if that is what you are after.

Back to Top
3BEPb View Drop Down
Groupie
Groupie


Joined: 07 August 2003
Location: United States
Status: Offline
Points: 81
Post Options Post Options   Thanks (0) Thanks(0)   Quote 3BEPb Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2003 at 10:50pm

OR:

Set oRS = conn.Execute(SQL)
If oRS.RecordCount=0 Then
    response.write "No one has registered for this tender"
Else

While Not oRS.EOF
%>
<TR ALIGN="center" bgcolor="<% = strTableBorderColour %>">

<TD><input type="text" name="FirstName" size="12" value="<%=oRS("FirstName")%>"</TD
>
<TD><input type="text" name="LastName" size="12" value="<%=oRS("LastName")%>"</TD
>
<TD><input type="text" name="Company" size="28" value="<%=oRS("Company")%>"</TD
>
<TD><input type="text" name="Position" size="18" value="<%=oRS("Position")%>"</TD
>
<TD><input type="text" name="Email" size="30" value="<%=oRS("Email")%>"</TD
>
<TD><input type="text" name="Download" size="25" value="<%=oRS("Download")%>"</TD
>
</TR>

<%
oRS.MoveNext
Wend
End If

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: 10 September 2003 at 7:33am
Yeah, I am not sure if he was looking for empty table or record in a certain field.
Back to Top
 Post Reply Post Reply

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.