ASP if statement

Hi Experts,

I have created a mood monitor to monitor the companies moods:

http://ec2-174-129-188-146.compute-1.amazonaws.com/NewPoll/development-rich-3.asp

It reads results from a database and will only display results if someone has voted...


I have a marquee at the bottom displaying the amount of votes with a message, although i now need an IF statement to tackle single votes:

Unfortunately, there are 2people in Bournemmouth who are Angry!

I need an IF statement so that if one person has voted, it will read:

Unfortunately, there IS ONE PERSON in Bournemmouth who IS Angry!

<!doctype html>

 

<html>

 

<head>

<script language="javascript"> 

function toggle() {

       var ele = document.getElementById("toggleText");

       

       if(ele.style.display == "block") {

              ele.style.display = "none";

              text.innerHTML = "show";

       }

       else {

              ele.style.display = "block";

              text.innerHTML = "hide";

       }

} 

</script>

 

<title>DEVELOPMENT</title>

 

<meta name="viewport" content="width=device-width, user-scalable=no" />

 

<style type="text/css">

 

body
{
    font: 16pt sans-serif;

}


	* { margin:0 ; padding:0 }
	#hidden-5 { background:#036 ; color:#FFF ; text-align:center;margin-left:20px;margin-right:200px}
	#toggle { display:none }
	
table{margin-left:auto;
margin-right:auto;}	


</style>



<script language="JavaScript">
<!--
 
function showHide(HID,IMG) {
        if (document.getElementById(IMG).src.indexOf('expand') != -1) {
                document.getElementById(IMG).src='/images/collapse.gif';
                document.getElementById(HID).className='visibleRow';
        } else {
                document.getElementById(IMG).src='/images/expand.gif';
                document.getElementById(HID).className='hiddenRow';
        }
}
 
// -->
</script>
<script type="text/JavaScript">
<!-- Chief...
function toggle(d)
{
	var o=document.getElementById(d);
	o.style.display=(o.style.display=='none')?'block':'none';
	setTimeout(function () {document.getElementById ('one').style.display='none'}, 10000);
}
-->
</script>

<!--<script type="text/javascript" src="show_hide_slide.js"></script> -->

</head>

 

<!--<body bgcolor="#FFFFFF"> -->

 

<!--<body style="background:transparent"> -->
<!--<body onload="setup();"> -->
<body>
<a href="javascript:;" onClick="toggle('one');"><img src="top1.png" style="height:250px;width:250pxpadding-top: 3px; position: absolute;    right: 15px;top:0;border:none;"></a>
<div id="one" style="margin-left:15px;background-color:#3399FF; display:none; width:98%; height:100%;margin-right:100px;">
<!--<div id="hidden-5" style="display:block;"> -->
<%

Dim Conn

Dim rs

Dim strSQL

Dim Move

Dim PollName

 

Dim Location

Dim Happy

Dim Sad

Dim OK

Dim Angry

 

Dim HappyPic

Dim SadPic

Dim AngryPic

Dim OKPic

 

' Setup the Image URL's

 

HappyPic = "happy.png"

OKPic = "OK.png"

SadPic = "Sad.png"

AngryPic = "angry.png"

 

strTest = "testdate"

 

Happy = 0

Sad = 0

Angry = 0

OK = 0

 

strSQL = "SELECT tblPoll.Location, Locations.LocationName, Sum(tblPoll.Happy) AS SumOfHappy, Sum(tblPoll.OK) AS SumOfOK, Sum(tblPoll.Sad) AS SumOfSad, Sum(tblPoll.Angry) AS SumOfAngry, tblPoll.date_added FROM Locations INNER JOIN tblPoll ON Locations.LocationID = tblPoll.Location GROUP BY tblPoll.Location, Locations.LocationName, tblPoll.date_added HAVING (((tblPoll.date_added)=Date())) ORDER BY tblPoll.Location;"

' Get the Like and Unlike values for this poll from the database

 

' Setup database connection

 

set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application("cn_ConnectionString")

set rs = Server.CreateObject("ADODB.Recordset")

 

on error resume next

 

rs.Open strsql, conn', 1, 2 

rs.MoveFirst

 Response.write "<table cellpadding='100'>"
 
  Response.write "<tr>"

if err = 0 then

    do until rs.eof

        Location = rs("LocationName")

        Happy     = rs("SumOfHappy") ' add here

        Sad   = rs("SumOfSad") ' add 2 more

        Angry   = rs("SumOfAngry") ' add 2 more

        OK   = rs("SumOfOK") ' add 2 more


 
 
 

        Response.write "<td><b style='color:white'>Location - " & Location &  "&nbsp;&nbsp;&nbsp;</b><br>"

        Response.write "Happy People: " & happy & "<br/>"

        Response.write "OK People: " & OK & "<br/>"

        Response.write "Sad People: " & sad & "<br/>"
        Response.write "No.Angry People: " & Angry & "<br/><br/></td>"




        rs.movenext

    loop

else

        Response.write "Nobody has voted today" 

end if
Response.write "</tr>"
Response.write "</table>"
on error goto 0

 

rs.Close

strSql = ""

conn.Close

 

set rs=nothing

set conn=nothing

 

%>
</div>
<!--<p><a href="#" onclick="toggle();" id="toggle">Toggle the header</a></p> -->

 

<%

 

Response.CacheControl = "no-cache"

 


 

 

 

 

    %> 

 


 

    <!-- like -->

 

<center>      <img src="welcome.png"></center>

 

       <div style="width:100%;padding-top:100px;display:block;">

 

&nbsp;&nbsp;

 

  

<!--<img src="top.png" style="padding-top: 3px; position: absolute;    right: 100px;top:0" name="answer" value="Show Div" onclick="toggle()" /> -->

<div id="toggleText" style="position:absolute;z-index:999;top:755px;width:400px;"> 

 



    </div>

        <a href="dev-results.asp?=&move=up" target="_blank" ><img src="happy.png" style="border:none;position:absolute;"></a>

        <a href="dev-results.asp?=&move=down2"><img src="ok.png" style="border:none;position:absolute;right:1120px;"></a>

        <a href="dev-results.asp?=&move=down" ><img src="sad.png" style="border:none;position:absolute;right:620px;"></a>     

        <a href="dev-results.asp?=&move=up1" ><img src="angry.png" style="border:none;position:absolute;right:120px;"></a>

    </div>
<%
strTest = "testdate"

Happy = 0

Sad = 0

Angry = 0

OK = 0

 'Change the location per site

strSQL = "SELECT tblPoll.Location, Sum(tblPoll.Happy) AS SumOfHappy, Sum(tblPoll.OK) AS SumOfOK, Sum(tblPoll.Sad) AS SumOfSad, Sum(tblPoll.Angry) AS SumOfAngry, tblPoll.date_added FROM tblPoll GROUP BY tblPoll.Location, tblPoll.date_added HAVING (((tblPoll.Location)=1) AND ((tblPoll.date_added)=Date()));"

 

 

' Get the Like and Unlike values for this poll from the database

' Setup database connection

set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application("cn_ConnectionString")

set rs = Server.CreateObject("ADODB.Recordset")

 

on error resume next

rs.Open strsql, conn', 1, 2 

rs.MoveFirst

'if err = 0 then

Happy     = rs("SumOfHappy") ' add here

Sad   = rs("SumOfSad") ' add 2 more

Angry   = rs("SumOfAngry") ' add 2 more

OK   = rs("SumOfOK") ' add 2 more

 

on error goto 0

       

rs.Close

strSql = ""

 

conn.Close

set rs=nothing

set conn=nothing



%>


 <div style="position:relative;top:300px;background:#54c5d0;border: 2px solid black;height:50px;">
<marquee style="backround:black;color:white;position:relative;top:5px;"><img src="happy.png" style="height:30px;width:35px"><% Response.write "Currently, there are " & happy & " Happy people in Bournemouth &nbsp;  "%> <img src="ok.png" style="height:30px;width:30px">  <% Response.write "There are " & OK & " people in Bournemouth who are in an OK mood   "%> <img src="sad.png" style="height:30px;width:35px"> <% Response.write "How many agrey people are there in Bournemouth?" & sad & " people in the Bournemouth Office who are sad  "%><img src="angry.png" style="height:30px;width:35px">   <% Response.write "Unfortunately, there are " & Angry & "people in Bournemmouth"%></marquee>

</body>

 

</html>       

Open in new window


Any help would be appreciated,

Thanks,
Richiep86Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You need to create some conditional strings based on the values from the db - so take out the text that is sensitive to the number and wrap that in an if - assiging to a variable. Use the variable in the sentence when you output it
Happy     = rs("SumOfHappy") ' add here
if Happy == 1 then
   strHappy = "is ONE Happy PERSON"
else
   strHappy = "are " & Happy & " Happy people"
end if

Sad   = rs("SumOfSad") ' add 2 more
if Sad == 1 then
   strSad = "is ONE Sad PERSON"
   strSadCon = "is"
else
   strSad = "are " & Sad & " Sad people"
   strSadCon = "are"
end if

Angry   = rs("SumOfAngry") ' add 2 more
if Angry == 1 then
   strAngry = "is ONE Angry PERSON"
else
   strAngry = "are " & Angry & " Angry people"
end if

OK   = rs("SumOfOK") ' add 2 more
if OK  == 1 then
   strOK = "is ONE OK PERSON"
   strOkCon = "is"
else
   strOK = "are " & OK  & "  OK people"
   strOkCon = "are"
end if
...
%>

Open in new window

<marquee style="backround:black;color:white;position:relative;top:5px;">
<img src="happy.png" style="height:30px;width:35px">
<% Response.write "Currently, there " & strHappy & "  in Bournemouth &nbsp;  "%>
<img src="ok.png" style="height:30px;width:30px">
 <% Response.write "There " & strOk & "  in Bournemouth who " & strOkCon & "  in an OK mood   "%>
<img src="sad.png" style="height:30px;width:35px">
<% Response.write "How many angry people are there in Bournemouth?" & strSad & " in the Bournemouth Office who " & strSadCon & " sad  "%>
<img src="angry.png" style="height:30px;width:35px">
 <% Response.write "Unfortunately, there " & strAngry & " in Bournemmouth"%></marquee>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richiep86Author Commented:
Execellent - thanks!
0
Julian HansenCommented:
You are welcome - thanks for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.