---
title: "Topplista fel"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/157655-topplista-fel"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "SGuncel"
published: "2007-02-28T13:33:37.000Z"
updated: "2007-03-04T22:13:40.000Z"
replies: 4
views: 423
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/157655-topplista-fel"
---

# Topplista fel

## #1 — SGuncel, 2007-02-28T13:33Z

Alla användare får samma medelbetyg och jag får inte personen som ligger etta eller har bästa medelbetyget.

```
<!-- #include file="Inc/Conn.asp" --><!-- #include file="Inc/Check.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="Content-Language" content="sv">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="copyright" content="">

<title></title>
<link rel="stylesheet" href="_Style/SidansStyle.css" type="text/css">

<SCRIPT type="text/javascript" src="../postnr/jsPostNr.asp" onreadystatechange="if (this.readyState=='complete') window.status=''; else window.status='Script: ' + this.readyState;" defer>
</SCRIPT>

</head>

<body>
<%
SQL = "Select * from TLUsers WHERE UsrID ="&SafeSQL(Session("UsrID"))&""
	Set ObjRS= ObjConn.execute(SQL)
	
	Function Age(datBorn)
  Age = DateDiff("yyyy", datBorn, Date())
  If (Month(Date()) < Month(datBorn)) or _
  (Month(Date()) = Month(datBorn) and Day(Date()) < Day(datBorn)) Then Age = Age -1
End Function
	
	Dim strVart_page , strVart_Query, strVart
strVart_page     = Mid(Request.ServerVariables("PATH_INFO"),1)
strVart_Query    = Request.ServerVariables("QUERY_STRING")

If Len(strVart_Query) > 0 Then
    strVart = strVart_page &"?"& strVart_Query
        Else
    strVart = strVart_page
End If

dim strVart_LinkName, strVart_Name
strVart_LinkName	= ("Spanar in i topplistan")

strVart_Name = strVart_LinkName

ObjConn.Execute("UPDATE TLUsers SET UsrWhere = '" & strVart & "', UsrWhereName = '" & strVart_Name & "' WHERE UsrID = "&SafeSQL(Session("UsrID")) & "")
%>
<table cellpadding="0" cellspacing="0" width="705">

<tr>
<td height="5">
<img src="../_Grafik/Profil_Vanster_Uppe.gif" alt="" width="9" height="7"></td>
<td height="7" style="background-image: url('../_Grafik/Profil_Uppe.gif');" width="666"></td>
<td height="5">
<img src="../_Grafik/Profil_Hoger_Uppe.gif" alt="" width="15" height="7"></td>
</tr>

<tr>
<td width="9" style="background-image: url('../_Grafik/Profil_Vanster.gif');" height="525"></td>
<td width="681" height="197">
              <table width="100%"  border="0" cellspacing="0" cellpadding="0" height="23" id="table4">
                <tr>
                  <td width="259" style="background-image: url('../_Grafik/Profil_Meny_Stor.gif');" height="23" style="padding: 3px">
                                Topplistan</td>
               <td width="83" style="background-image: url('../_Grafik/Profil_Meny_Mellan.gif');" height="23">
                <img src="../_Grafik/Pix.gif" width="10" height="10">
                <a href="../UsrRank/UsrRank.asp">
				Alla</a></td>
                               <td width="83" style="background-image: url('../_Grafik/Profil_Meny_Mellan.gif');" height="23">
                <img src="../_Grafik/Pix.gif" width="10" height="10">
                <a href="../UsrRank/UsrRankBoys.asp">
				Killar</a></td>
                               <td width="83" style="background-image: url('../_Grafik/Profil_Meny_Mellan.gif');" height="23">
                <img src="../_Grafik/Pix.gif" width="10" height="10">
               	<a href="../UsrRank/UsrRankGirls.asp">
				Tjejer</a></td>
                               <td width="83" style="background-image: url('../_Grafik/Profil_Meny_Mellan.gif');" height="23">
                &nbsp;</td>
                              <td width="90" style="background-image: url('../_Grafik/Profil_Meny_Liten.gif');" height="23">
                </td>
                </tr>
                </table>
                
                              <table width="100%"  border="0" cellspacing="0" cellpadding="0" height="504">
                <tr>
                              <td width="506" height="504" valign="top" style="padding: 3px;">
                              <%
                              Set Count = ObjConn.Execute("Select SUM(VoteGrade) AS vgrade FROM Votes order by vgrade DESC")
                       
								VoteGrade = Cint(Count("vgrade"))
                              
                              Set ObjRS2 = ObjConn.Execute("Select * FROM TLUsers where TotalVote LIMIT 10")
                              
                              	TotalVote = Cint(ObjRS("TotalVote"))
                              %>
                              <div><%
                              IF ObjRS2.Eof then
					Response.Write "Du har inga besökare."
								Else
								%>
								</div>
                            
<table width="485" cellspacing="1" cellpadding="0" bgcolor="#000000" align="left">
	
	<%
		For i = 1 To 10
		Do Until ObjRS2.EOF
	%>	
	<tr>
		<td background="../_Grafik/UsrRankBorder.gif" width="16" align="center">
		<b></b></td>
		<td bgcolor="#FFFFFF" valign="top" style="padding: 3px;" width="460">
		
<table width="457" cellspacing="1" cellpadding="0" height="114">
	<tr>
		<td valign="top" style="padding: 3px;" width="99">
		<img src="<%=ObjRS2("UsrPic")%>" border="1" width="90" height="110"></td>
		
		<td valign="top" style="padding: 3px;">
		<b>
		<a href="../UsrProfile/Profil.asp?UsrId=<%=ObjRS2("UsrId")%>"><%=ObjRS2("UsrTLAlias")%></a></b> -
		                <% 
                If ObjRS2("UsrSex")="Kille" Then
    			Response.Write "P"
    			Else
    			Response.Write "F"
    			End If
    			%>

<%=Age(DateSerial(ObjRS2("UsrAgeYear"), ObjRS2("UsrAgeMonth"), ObjRS2("UsrAgeDay")))%> från <%=ObjRS2("UsrLiveLoc")%> <br>
		<br>
		<b>Antal röster:</b> <%=ObjRS2("TotalVote")%>
		<br>
		<b>Medelbetyg:</b> 
		<%
			Snitt = Round(VoteGrade/TotalVote,2)

			Response.Write ""&Snitt&""
		%>
		</td>
		
	</tr>
</table>
		</td>		
	</tr>
			
<%
	ObjRS2.MoveNext
	Loop
	Next
	
	ObjRS.Close : Set ObjRS = nothing
	ObjRS2.Close : Set ObjRS2 = nothing
	ObjConn.Close : Set ObjConn = Nothing

		End if
%>
</table>

								</td>
                </td>
                </tr>
                </table>
                
                </td>
<td width="15" style="background-image: url('../_Grafik/Profil_Hoger.gif');" height="197"></td>
</tr>

<tr>
<td height="5">
<img src="../_Grafik/Profil_Vanster_Nere.gif" alt="" width="9" height="6"></td>
<td height="5" style="background-image: url('../_Grafik/Profil_Nere.gif');"></td>
<td height="5">
<img src="../_Grafik/Profil_Hoger_Nere.gif" alt="" width="15" height="6"></td>
</tr>

<tr>
<td height="5">
<img src="../_Grafik/Profil2_Vanster_Nere.gif" alt="" width="9" height="16"></td>
<td height="5" style="background-image: url('../_Grafik/Profil2_Nere.gif');"></td>
<td height="5">
<img src="../_Grafik/Profil2_Hoger_Nere.gif" alt="" width="15" height="16"></td>
</tr>
</table>

</body>

</html>
```

Permalänk: https://www.webforum.nu/p/157655

## #2 — SGuncel, 2007-03-04T01:30Z

Nån som vill hjälpa? :)

Permalänk: https://www.webforum.nu/p/1942046

## #3 — emission, 2007-03-04T13:18Z

1\. Du har fortfarande en konstig SQL-sats. 

"Select \* FROM TLUsers where TotalVote LIMIT 10"

Den kan inte stämma.

2\. Du har fortfarande en for-loop. Ta bort den.

3\. Du beräknar medelbetyg med samma värden varje gång. Det borde åtminstone vara TotalVote från objRS2.

Permalänk: https://www.webforum.nu/p/1942114

## #4 — SGuncel, 2007-03-04T18:43Z

Hur ska jag göra så? :S

Permalänk: https://www.webforum.nu/p/1942195

## #5 — emission, 2007-03-04T22:13Z

Börja med punkt 1. Något försöker du göra med SQL-satsen, men vad? Vilka 10 användare?

Permalänk: https://www.webforum.nu/p/1942297

---

Tråden på webben: https://www.webforum.nu/amne/asp/157655-topplista-fel
