Avatar billede tzag_dk Nybegynder
07. april 2004 - 16:40 Der er 59 kommentarer og
5 løsninger

Placering i recordset

Hej...

Hvordan laver man så at man kan vise én placering af et billede´s stemmer?
DB´en ser sådan her ud:

hotstemmer
--------------------------
id---hotbillederID---point
5----54--------------7----
6----65--------------5----
7----54--------------8----
8----75--------------9----
osv.

Point er fra 1 til 10.

På forhånd tak!
// Rene
Avatar billede loukas Mester
07. april 2004 - 22:55 #1
øøh, mener du:

billede med 9 points er nummer et
billede med 8 points er nummer to

osv.. ??
Avatar billede tzag_dk Nybegynder
08. april 2004 - 17:13 #2
Som du kan se, så er der 2 stemmer på hotbillederID 54.
Og så skal man udregne gennemsnittet.
Tilsidst skal den skrive hvilken placering billedet er.

Er du med på det nu? :-)
Avatar billede montago Praktikant
08. april 2004 - 22:02 #3
nåååår... jeg er med på hvad du mener... kommer med et svar om lidt
Avatar billede montago Praktikant
08. april 2004 - 22:17 #4
skal  bare lige høre om du stadig har brug for hjælp...
Avatar billede montago Praktikant
08. april 2004 - 22:40 #5
ANYWAY...

åbn  din database...

sql1 = "select destinct hotbillederID from hotstemmer"
destSel = conn.execute("sql1")

if not destSel.eof then
sql2 = "select sum(point) from hotstemmer where hotbillederID = '" & destSel("hotbillederID") & "'"
  sumselect = conn.execute("sql2")
    if not sumselect.eof then
    response.write sumselect("") / destsel.total
end if
end if

sådan noget lignende....
Avatar billede montago Praktikant
08. april 2004 - 22:42 #6
først finder du hver enkelt forskellige hotbillederID-numre...
derved har du en række unikke... id'er som du henter summen af søjlen fra...hvor søjlen er hotbillederID...

dividere med total records... og vupti
Avatar billede tzag_dk Nybegynder
10. april 2004 - 19:46 #7
Hej montago

Du må først og fremmest undskylde at jeg ikke lige har været her :-)
Men jeg syntes ikke at jeg kan få det til at virke, det er en mysql db jeg har.
Den laver følgende fejl:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'EOF'

// Rene
Avatar billede montago Praktikant
10. april 2004 - 19:48 #8
jaja... jeg kylte bare noget ud... idet jeg sad på en anden computer...

skal lige finde scriptet frem igen... har nemlig svaret...
Avatar billede tzag_dk Nybegynder
10. april 2004 - 20:00 #9
hehe... ok, det lyder godt :-)
Avatar billede montago Praktikant
10. april 2004 - 20:05 #10
Sådan her:

<%
    'Open Database
    DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
    DSN = DSN & "DBQ=" & Server.MapPath("Database.mdb")
    Conn.Open DSN
'make 1st SQL   
strSQL = "SELECT DESTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer
        strSQL2 = strSQL2 & "WHERE hotbillederID = '" & DestincSelection("hotbillederID") & "'"
        Set SumSelection = Conn.Execute(strSQL2)

        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer
        strSQL3 = strSQL2 & "WHERE hotbillederID = '" & DestincSelection("hotbillederID") & "'"
        Set NumSelection = Conn.Execute(strSQL3)
       
        Response.Write ( SumSelection("") / NumSelection.TotalRecords ) & "<br>"   
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
   
    Conn.Close
Set Conn = Nothing

%>
Avatar billede montago Praktikant
10. april 2004 - 20:06 #11
der skal nok nogle ganske få rettelser til før det virker...
Avatar billede tzag_dk Nybegynder
10. april 2004 - 20:57 #12
Hej igen.

Jeg kan simpelhent ikke få det til at virke. Det eks du har er også med en access db og ikke en mysql db. Kan det ikke have noget at sige?
Den kommer med denne fejl:

Microsoft OLE DB Provider for ODBC Drivers error '80040e09'

[TCX][MyODBC]Der er en fejl i SQL syntaksen nær 'WHERE hotbillederID = 58' på linje 1

/profil/hotbilleder/Default.asp, line 81


Sådan her ser min kode ud nu:
'make 1st SQL   
strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)

        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
       
        Response.Write ( SumSelection("") / NumSelection.TotalRecords ) & "<br>"   
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF

// Rene
Avatar billede ellebaek Nybegynder
10. april 2004 - 20:58 #13
strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & CInt(DestincSelection)("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)

        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL2 & " WHERE hotbillederID = " & CInt(DestincSelection)("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
       
        Response.Write ( SumSelection("") / NumSelection.TotalRecords ) & "<br>"   
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF


Prøv det her...
Avatar billede montago Praktikant
10. april 2004 - 21:01 #14
jamen... problemet er jo at jeg ikke aner en dyt om MySQL... jeg kan kun SQL og Aceess og ASP...

hvad jeg har lavet vil virke... hvis din connection bare hedder Conn
OG du fjerner database forbindelsen... samt lukningen...
Avatar billede montago Praktikant
10. april 2004 - 21:01 #15
access var det altså...

men SQL er SQL... så det skulle virke
Avatar billede ellebaek Nybegynder
10. april 2004 - 21:23 #16
tzag -> Er feltet hotBillederID af typen tal i dine tabeller..
Og jeg har lige lidt rettelser til det jeg skrev før ;-)

strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & CInt(DestincSelection("hotbillederID")) & ""
        Set SumSelection = Conn.Execute(strSQL2)

        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & CInt(DestincSelection("hotbillederID")) & ""
        Set NumSelection = Conn.Execute(strSQL3)
       
        Response.Write ( SumSelection("") / NumSelection.TotalRecords ) & "<br>"   
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF


Samtidig gætter jeg på at det var en fejl at du har strSQL2 med i strSQL3..
Avatar billede montago Praktikant
10. april 2004 - 22:23 #17
hehe yup...
Avatar billede tzag_dk Nybegynder
11. april 2004 - 14:35 #18
Hej igen...
Nu laver den følgende fejl:

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

Default.asp, line 82

Dette her er linje 82:
Response.Write ( SumSelection("") / NumSelection.TotalRecords ) & "<br>"

// Rene
Avatar billede montago Praktikant
11. april 2004 - 14:50 #19
hmm... da jeg ikke helt ved hvordan man får SUM-værdien ud af SQL'en... skrev jeg blot 'SumSelection("")' hvilket jeg 'tror' giver resultatet...

NumSelection.TotalRecords tæller antallet af linier op, fundet via SQL3... netop de linier hvor hotbillederID er repressenteret...

.TotalRecords giver efter min hukkommelse antallet af records... det kan være forkert...
Avatar billede montago Praktikant
11. april 2004 - 15:05 #20
fuk
.totalrecords virker ikke...

de skal tælles op...
<%
strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & CInt(DestincSelection("hotbillederID")) & ""
        Set SumSelection = Conn.Execute(strSQL2)

        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & CInt(DestincSelection("hotbillederID")) & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            while not NumSelection.EOF
       
        Response.Write ( SumSelection("") / NumSelection_TotalRecords ) & "<br>"   
            NumSelection_TotalRecords = 0
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
%>
Avatar billede tzag_dk Nybegynder
11. april 2004 - 15:09 #21
okay.. men nu siger det loop whit out do
Men det ser da rigtig nok ud!
Avatar billede montago Praktikant
11. april 2004 - 15:11 #22
jaja... glemte at skrive loop
<%
strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & CInt(DestincSelection("hotbillederID")) & ""
        Set SumSelection = Conn.Execute(strSQL2)

        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & CInt(DestincSelection("hotbillederID")) & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            loop while not NumSelection.EOF
       
        Response.Write ( SumSelection("") / NumSelection_TotalRecords ) & "<br>"   
            NumSelection_TotalRecords = 0
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
%>
Avatar billede montago Praktikant
11. april 2004 - 15:18 #23
ARRGGH... så kan det også være ligemeget med SUM funktionen... lorte SQL...

her er det endelige svar ... som med 2 mio % sikkerhed virker !

strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT SUM(point) FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Count = SumSelection_Count + 1
            SumSelection.MoveNext
            loop while not SumSelection.EOF
        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
       
            Response.Write ( SumSelection_Count / NumSelection_TotalRecords ) & "<br>" 
            SumSelection_Count = 0 
            NumSelection_TotalRecords = 0
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
   
    Conn.Close
Set Conn = Nothing
Avatar billede montago Praktikant
11. april 2004 - 15:18 #24
fjern de sidste 2 linier... hehe
Avatar billede montago Praktikant
11. april 2004 - 15:20 #25
arrrgghhh... vent der mangler lige eeen lille ting som jeg har glemt...

strSQL = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        'make 2nd SQL
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Count = SumSelection_Count + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF
        'make 3rd SQL
        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
       
            Response.Write ( SumSelection_Count / NumSelection_TotalRecords ) & "<br>" 
            SumSelection_Count = 0 
            NumSelection_TotalRecords = 0
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF

giver

7,5
5
9
Avatar billede tzag_dk Nybegynder
11. april 2004 - 15:21 #26
Jeg syntes ikke at det ser rigtig ud...
Jeg tror ikke at vi er enige mht hvordan at det skal udskrives.
Det skal knu være én placering, lige som her på eksperten. Hvor at man kan se sin egen placering oppe i venstre hjørne:
Placering: 7.260

Men i hvert fald så vil jeg tro at der skal et ID ind et sted for at definere hvilket billede placeringen høre til...?

// Rene
Avatar billede montago Praktikant
11. april 2004 - 15:25 #27
jamen ihh... det er nemt nok...
Avatar billede tzag_dk Nybegynder
11. april 2004 - 15:28 #28
ok, det er bare fordi at jeg ikke lige kan overskue koden :-) hehe
Avatar billede montago Praktikant
11. april 2004 - 16:22 #29
hmm hvor mange informationer vil du have ud på en gang ?

er det "kun" placeringen eller er det alle HotBilleders point ? eller ??
Avatar billede montago Praktikant
11. april 2004 - 16:25 #30
strSQL = "SELECT hotbillederID FROM hotstemmer ORDER BY point desc"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Sum = SumSelection_Sum + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF

        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
   
            Avarage = SumSelection_Sum / NumSelection_TotalRecords
            SumSelection_Sum = 0 
            NumSelection_TotalRecords = 0
   
            IF  DestincSelection("hotbillederID") <> TempID THEN
                MegaString = MegaString & DestincSelection("hotbillederID") & "_" & Avarage & "¤"
            End if
            TempID = DestincSelection("hotbillederID")
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
   
    MegaArray = Split(MegaString,"¤")
    For ArrayCount = 0 to UBound(MegaArray) -1
        Rows = Split(MegaArray(ArrayCount),"_")
        if inStr(Rows(0),HER SKAL HotBillederID's ID indsættes- fx Session("ID") ) Then
            Response.Write Rows(0) & "..." & Rows(1) & "<br>"
        end if
    Next
Avatar billede tzag_dk Nybegynder
11. april 2004 - 16:28 #31
Det er kun placeringen :-)
Avatar billede montago Praktikant
11. april 2004 - 16:29 #32
hist pist... Done...

strSQL = "SELECT hotbillederID FROM hotstemmer ORDER BY point desc"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Sum = SumSelection_Sum + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF

        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
   
            Avarage = SumSelection_Sum / NumSelection_TotalRecords
            SumSelection_Sum = 0 
            NumSelection_TotalRecords = 0
   
            IF  DestincSelection("hotbillederID") <> TempID THEN
                MegaString = MegaString & DestincSelection("hotbillederID") & "_" & Avarage & "¤"
            End if
            TempID = DestincSelection("hotbillederID")
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
   
    MegaArray = Split(MegaString,"¤")
    For ArrayCount = 0 to UBound(MegaArray) -1
        Rows = Split(MegaArray(ArrayCount),"_")
        Placering = Placering + 1
        if inStr(Rows(0),"54") Then
            Response.WRite "Placering: " & Placering & "<br>"
            Response.Write "HotbillederID: " & Rows(0) & " <br> Point: " & Rows(1) & "<br>"
        end if
    Next
Avatar billede montago Praktikant
11. april 2004 - 16:30 #33
udskriver: 
-----------------
Placering: 2
HotbillederID: 54
Point: 7,5
Avatar billede montago Praktikant
11. april 2004 - 16:33 #34
sådan her... vil placeringen ikke være akkumuleret :

strSQL = "SELECT hotbillederID FROM hotstemmer ORDER BY point desc"
Set DestincSelection = Conn.Execute(strSQL)
    Do
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Sum = SumSelection_Sum + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF

        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DestincSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
   
            Avarage = SumSelection_Sum / NumSelection_TotalRecords
            SumSelection_Sum = 0 
            NumSelection_TotalRecords = 0
   
            IF  DestincSelection("hotbillederID") <> TempID THEN
                MegaString = MegaString & DestincSelection("hotbillederID") & "_" & Avarage & "¤"
            End if
            TempID = DestincSelection("hotbillederID")
           
    DestincSelection.MoveNext
    Loop While Not DestincSelection.EOF
   
    MegaArray = Split(MegaString,"¤")
    For ArrayCount = 0 to UBound(MegaArray) -1
        Rows = Split(MegaArray(ArrayCount),"_")
            if Rows(0) <> tmp then
            Placering = Placering + 1
            end if
            tmpID = Rows(0)
        if inStr(Rows(0),"65") Then
            Response.WRite "Placering: " & Placering & "<br>"
            Response.Write "HotbillederID: " & Rows(0) & " <br> Point: " & Rows(1) & "<br>"
        end if
    Next
Avatar billede tzag_dk Nybegynder
11. april 2004 - 16:45 #35
Nu begynder det at ligne noget :-)

Der er bare et bar små fejl, den udskriver følgende:
Score:9,00
Placering: 38
HotbillederID: 63
Point: 9
Placering: 40
HotbillederID: 63
Point: 9
Placering: 44
HotbillederID: 63
Point: 9
Placering: 46
HotbillederID: 63
Point: 9
Placering: 50
HotbillederID: 63
Point: 9
Placering: 52
HotbillederID: 63
Point: 9
Placering: 56
HotbillederID: 63
Point: 9
Placering: 58
HotbillederID: 63
Point: 9

Det er for ét billede, og det er jo lidt meget, hehe...
Og så kan jeg se at placeringen ikke passer, da at der kun er 7 billeder at stemme på :-)
Avatar billede tzag_dk Nybegynder
11. april 2004 - 16:46 #36
hov... sådan her:

Placering: 38
HotbillederID: 63
Point: 9
Placering: 40
HotbillederID: 63
Point: 9
Placering: 44
HotbillederID: 63
Point: 9
Placering: 46
HotbillederID: 63
Point: 9
Placering: 50
HotbillederID: 63
Point: 9
Placering: 52
HotbillederID: 63
Point: 9
Placering: 56
HotbillederID: 63
Point: 9
Placering: 58
HotbillederID: 63
Point: 9
Avatar billede montago Praktikant
11. april 2004 - 16:49 #37
hmmm jamen... så har jeg en ide om hvorfor...
Avatar billede montago Praktikant
11. april 2004 - 18:14 #38
Erstat 54 i ' strSQL5 = strSQL5 & " WHERE hotbillederID = " & 54 & "" '
med dit billedID

og forstør eller formindsk ArrayStørrelserne så det passer... (lige nu 500)


Dim HotBillederArray(500,1)
Dim PlaceringArr(500)

strSQL1 = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DistinctSelection = Conn.Execute(strSQL1)
    do
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DistinctSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Sum = SumSelection_Sum + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF

        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DistinctSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
   
            Avarage = SumSelection_Sum / NumSelection_TotalRecords
        HotBillederArray(DistinctSelection("hotbillederID"),0) = DistinctSelection("hotbillederID")
        HotBillederArray(DistinctSelection("hotbillederID"),1) = Avarage
       
        NumSelection_TotalRecords = 0
        SumSelection_Sum = 0
    DistinctSelection.MoveNext
    loop while not DistinctSelection.EOF
'sortering
    For i = UBound(HotBillederArray) - 1  To 1 Step - 1
        MaxVal = HotBillederArray(i,1)
        MaxIndex = i
   
        For j = 0 To i
            If HotBillederArray(j,1) > MaxVal Then
                MaxVal = HotBillederArray(j,1)
                MaxIndex = j
            End If
        Next
   
        If MaxIndex < i Then
            HotBillederArray(MaxIndex,1) = HotBillederArray(i,1)
            HotBillederArray(MaxIndex,0) = HotBillederArray(i,0)
            HotBillederArray(i,1) = MaxVal
            HotBillederArray(i,0) = MaxVal
        End If
    Next
    For ReadArr = 0 to 500
        If HotBillederArray(ReadArr,1) <> "" then
        placering = placering + 1
        PlaceringArr(placering) = HotBillederArray(ReadArr,1)
        end if
    Next   
'---------------------------
        strSQL4 = "SELECT * FROM hotstemmer "
        strSQL4 = strSQL4 & " WHERE hotbillederID = " & 54 & ""
        Set SumSelection2 = Conn.Execute(strSQL4)
            do
                SumSelection2_Sum = SumSelection2_Sum + SumSelection2("point")
            SumSelection2.MoveNext
            loop while not SumSelection2.EOF

        strSQL5 = "SELECT * FROM hotstemmer "
        strSQL5 = strSQL5 & " WHERE hotbillederID = " & 54 & ""
        Set NumSelection2 = Conn.Execute(strSQL5)
            do
                NumSelection2_TotalRecords = NumSelection2_TotalRecords + 1
            NumSelection2.MoveNext
            Loop While not NumSelection2.EOF
   
            Avarage2 = SumSelection2_Sum / NumSelection2_TotalRecords
               
    For TotalPlacering = 0 to 500
        if PlaceringArr(TotalPlacering) = Avarage2 Then
        Response.Write "Placering: " & TotalPlacering & ": " & PlaceringArr(TotalPlacering) & " Point <br>"
        end if
    Next
Avatar billede montago Praktikant
11. april 2004 - 18:34 #39
hvis der er 2 billeder som har samme score... vil de få samme placering... fx en delt andenplads...
Avatar billede tzag_dk Nybegynder
13. april 2004 - 10:01 #40
hej montago

Scriptet virker som det skal :-)
Dog har jeg et lille problem når jeg sætter det ind.
Jeg lister mine billeder under hinanden med en masse data til burgeren, den viser fint den første loop, men når den skal lave nr to loop så laver den fejl i linje 70, og der står der:
Dim HotBillederArray(500,1)

Ved du hvad der kan være galt? :-)
Avatar billede montago Praktikant
13. april 2004 - 10:07 #41
hmm...

Alt i scripted som står over '---------------------------
må kun køres een gang !... derfor skal den del af scriptet placeres i toppen af din asp-side . og uden for loops og løkker...

det der står under kan du placere i loops, eller der hvor dit billede hentes...
Avatar billede montago Praktikant
13. april 2004 - 10:13 #42
jeg har dog selv opdaget det problem, at hvis 2 billeder har samme gennesnitsværdi, vil begge placeringer blive vist... hvilket er lidt skod...

fx.. hvis billedID = 54 og 75, begge har 2 stemmer, og begge stemmer er på 7 og 8, vil 54* og 75* have 7,5 i snit...

og følgende blive vist:

Placering: 2: 7,5 Point
Placering: 3: 7,5 Point

men det er til at leve med... du kan evt. lukke for nummer 2 visning med..

For TotalPlacering = 0 to 500
    If visning = 0 then
        if PlaceringArr(TotalPlacering) = Avarage2 Then
        Response.Write "Placering: " & TotalPlacering & ": " & PlaceringArr(TotalPlacering) & " Point <br>"
        end if
    end if
    visning = visning + 1
Next
visning = 0
Avatar billede montago Praktikant
13. april 2004 - 10:13 #43
så vil det billede som har mere end 7,5 i snit, blive nummer 4 i rækken...
som det jo egentligt er ;-)
Avatar billede montago Praktikant
13. april 2004 - 10:15 #44
ermm... alt over '---------- skal selvfølgelig være UNDER din database opkopling... men stadig uden for loop
Avatar billede tzag_dk Nybegynder
13. april 2004 - 10:30 #45
ok... nu kan den liste alle billederne, men det er kun det første billede som der kommer en placering på, underligt :-)
Avatar billede montago Praktikant
13. april 2004 - 10:50 #46
arghh... jeg store fjols...

For TotalPlacering = 0 to 500
    if PlaceringArr(TotalPlacering) = Avarage2 Then
      If visning = 0 then
          Response.Write "Placering: " & TotalPlacering & ": " & PlaceringArr(TotalPlacering) & " Point <br>"
        end if
        visning = visning + 1
    end if
Next
visning = 0
Avatar billede tzag_dk Nybegynder
13. april 2004 - 10:57 #47
Heller ikke... :-(
Kan det have noget at gøre med at det første stykke kode kun køres én gang?
Avatar billede montago Praktikant
13. april 2004 - 13:26 #48
nejda... den første kode bygger et array op, som den anden del, så læser fra og sammenligner med...
Avatar billede tzag_dk Nybegynder
13. april 2004 - 15:26 #49
ok, men så forstår jeg bare ikke at den kun viser placeringen på det første billede.
Vil du se koden fra den loop?
Avatar billede montago Praktikant
13. april 2004 - 15:42 #50
kom bare an... post hele skidtet !
Avatar billede tzag_dk Nybegynder
13. april 2004 - 16:06 #51
hehe... Du er sku cool nok :-)

Her er det:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
site = "profil"
subsite = "profilhotbilleder"
%>
<!--#include virtual="/includeall.asp"-->
<!--#include virtual="/top.asp"-->
<!--#include virtual="/secure/access.asp"-->
<script language="javascript" type="text/javascript">
<!-- Centrering af pop-up vindue start
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// Centrering af pop-up vindue slut-->
</script>
<table width="772"  border="0" align="center" cellpadding="0" cellspacing="0" class="borderTop">
  <tr bgcolor="#FFFFFF">
    <td width="144" align="left" valign="top"><!--#include virtual="/left.asp"--></td>
    <td width="523" align="left" valign="top"><br>
      <br>
      <table width="448" height="134" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
          <tr>
            <td align="left" valign="top"><%
sqlfind="Select Count(*) as Found from hotbilleder where (profilerID = '" & Session("id") & "')"
set RSfind = Conn.execute(sqlfind)
%>              <%if RSfind("Found") = "0" then%>              <br>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="2%">&nbsp;</td>
                  <td width="95%">                  Du har ikke tilf&oslash;jet nogle hot billeder...                </td>
                  <td width="3%">&nbsp;</td>
                </tr>
              </table>
              <%else
'---- PLACERING DEL 1 START------
Dim HotBillederArray(500,1)
Dim PlaceringArr(500)

strSQL1 = "SELECT DISTINCT hotbillederID FROM hotstemmer"
Set DistinctSelection = Conn.Execute(strSQL1)
    do
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DistinctSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Sum = SumSelection_Sum + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF

        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DistinctSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
   
            Avarage = SumSelection_Sum / NumSelection_TotalRecords
        HotBillederArray(DistinctSelection("hotbillederID"),0) = DistinctSelection("hotbillederID")
        HotBillederArray(DistinctSelection("hotbillederID"),1) = Avarage
       
        NumSelection_TotalRecords = 0
        SumSelection_Sum = 0
    DistinctSelection.MoveNext
    loop while not DistinctSelection.EOF
'sortering
    For i = UBound(HotBillederArray) - 1  To 1 Step - 1
        MaxVal = HotBillederArray(i,1)
        MaxIndex = i
   
        For j = 0 To i
            If HotBillederArray(j,1) > MaxVal Then
                MaxVal = HotBillederArray(j,1)
                MaxIndex = j
            End If
        Next
   
        If MaxIndex < i Then
            HotBillederArray(MaxIndex,1) = HotBillederArray(i,1)
            HotBillederArray(MaxIndex,0) = HotBillederArray(i,0)
            HotBillederArray(i,1) = MaxVal
            HotBillederArray(i,0) = MaxVal
        End If
    Next
    For ReadArr = 0 to 500
        If HotBillederArray(ReadArr,1) <> "" then
        placering = placering + 1
        PlaceringArr(placering) = HotBillederArray(ReadArr,1)
        end if
    Next 
'---- PLACERING DEL 1 SLUT------

SQLhotbilleder = "select * from hotbilleder where profilerID=" & session("id")
set RShotbilleder = conn.execute(SQLhotbilleder)
do while not RShotbilleder.EOF%>
              <br>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr align="left" valign="top">
                  <td width="22%"><img src="/images/hotbilleder/thumb/<%=RShotbilleder("billede")%>" width="100"><br>
                    <a href="ret.asp?id=<%=RShotbilleder("id")%>" onclick="NewWindow(this.href,'Copyright','450','150','no','center');return false">Ret</a> - <a href="slet.asp?id=<%=RShotbilleder("id")%>" onclick="NewWindow(this.href,'Copyright','450','150','no','center');return false">Slet</a></td>
                  <td width="3%">&nbsp;</td>
                  <td width="41%">Tilf&oslash;jet: <%=DanskDatoTid(RShotbilleder("dato"))%><br>
Status:
  <%if RShotbilleder("godkendt") = "0" then%>
  <span style="color: #993333">Venter p&aring; godkendelse!</span>
  <%else%>
  <span style="color: #009900">Godkendt</span>
  <%end if

SQLgen2 = "SELECT COUNT(*) AS count FROM hotstemmer where hotbillederID = " & RShotbilleder("id")&""
Set RSgen2 = Conn.Execute(SQLgen2)

if not RSgen2("count") = "0" then
SQLgen1 = "SELECT SUM(point) FROM hotstemmer where hotbillederID = " & RShotbilleder("id")&""
Set RSgen1 = Conn.Execute(SQLgen1)             

gennemsnit = RSgen1(0)/RSgen2("count")
end if
%>
  <br>
Score: <%if not RSgen2("count") = "0" then%> <%Response.Write(FormatNumber(gennemsnit,2)) %> (<%=RSgen2("count")%> stemmer)<%else%> Ingen stemmer!<%end if%><br>
<%
if not RSgen2("count") = "0" then
 
'---- PLACERING DEL 2 START------
        strSQL4 = "SELECT * FROM hotstemmer "
        strSQL4 = strSQL4 & "WHERE hotbillederID = " & RShotbilleder("id") & ""
        Set SumSelection2 = Conn.Execute(strSQL4)
            do
                SumSelection2_Sum = SumSelection2_Sum + SumSelection2("point")
            SumSelection2.MoveNext
            loop while not SumSelection2.EOF

        strSQL5 = "SELECT * FROM hotstemmer "
        strSQL5 = strSQL5 & " WHERE hotbillederID = " & RShotbilleder("id") & ""
        Set NumSelection2 = Conn.Execute(strSQL5)
            do
                NumSelection2_TotalRecords = NumSelection2_TotalRecords + 1
            NumSelection2.MoveNext
            Loop While not NumSelection2.EOF
   
            Avarage2 = SumSelection2_Sum / NumSelection2_TotalRecords
               
For TotalPlacering = 0 to 500
    if PlaceringArr(TotalPlacering) = Avarage2 Then
      If visning = 0 then
          Response.Write "Placering: " & TotalPlacering & ": " & PlaceringArr(TotalPlacering) & " Point <br>"
        end if
        visning = visning + 1
    end if
Next
visning = 0
else
response.Write("MIN. 20 stemmer")
end if
'---- PLACERING DEL 2 SLUT------
%>
<br>
<br>
<a href="/default.asp?mode=picture&pictureID=<%=RShotbilleder("id")%>">Se billede</a><br>
<a href="/profil/hotbilleder/sestemmer/?id=<%=RShotbilleder("id")%>">Se stemmer</a> </td>
                  <td width="34%" valign="bottom">
                 
<%
    Sql = "SELECT count(*) as '0' FROM hotstemmer WHERE profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS0 = conn.execute(sql)
   
    if not RS0("0") = "0" then
    Sql = "SELECT count(*) as '1' FROM hotstemmer WHERE point = '1' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS1 = conn.execute(sql)
    Sql = "SELECT count(*) as '2' FROM hotstemmer WHERE point = '2' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS2 = conn.execute(sql)
    Sql = "SELECT count(*) as '3' FROM hotstemmer WHERE point = '3' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS3 = conn.execute(sql)
    Sql = "SELECT count(*) as '4' FROM hotstemmer WHERE point = '4' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS4 = conn.execute(sql)
    Sql = "SELECT count(*) as '5' FROM hotstemmer WHERE point = '5' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS5 = conn.execute(sql)
    Sql = "SELECT count(*) as '6' FROM hotstemmer WHERE point = '6' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS6 = conn.execute(sql)
    Sql = "SELECT count(*) as '7' FROM hotstemmer WHERE point = '7' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS7 = conn.execute(sql)
    Sql = "SELECT count(*) as '8' FROM hotstemmer WHERE point = '8' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS8 = conn.execute(sql)
    Sql = "SELECT count(*) as '9' FROM hotstemmer WHERE point = '9' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS9 = conn.execute(sql)
    Sql = "SELECT count(*) as '10' FROM hotstemmer WHERE point = '10' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS10 = conn.execute(sql)
   
    varTotal = RS0("0")
    varTalt1 = RS1("1")
    varTalt2 = RS2("2")
    varTalt3 = RS3("3")
    varTalt4 = RS4("4")
    varTalt5 = RS5("5")
    varTalt6 = RS6("6")
    varTalt7 = RS7("7")
    varTalt8 = RS8("8")
    varTalt9 = RS9("9")
    varTalt10 = RS10("10")
    ialt1 = varTalt1/varTotal*100
    ialt2 = varTalt2/varTotal*100
    ialt3 = varTalt3/varTotal*100
    ialt4 = varTalt4/varTotal*100
    ialt5 = varTalt5/varTotal*100
    ialt6 = varTalt6/varTotal*100
    ialt7 = varTalt7/varTotal*100
    ialt8 = varTalt8/varTotal*100
    ialt9 = varTalt9/varTotal*100
    ialt10 = varTalt10/varTotal*100
%>                 
                 
                  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr align="center" valign="bottom">
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt1,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt2,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt3,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt4,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt5,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt6,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt7,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt8,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt9,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt10,0)%>"></td>
                    </tr>
                    <tr align="center" valign="top">
                      <td>1</td>
                      <td>2</td>
                      <td>3</td>
                      <td>4</td>
                      <td>5</td>
                      <td>6</td>
                      <td>7</td>
                      <td>8</td>
                      <td>9</td>
                      <td>10</td>
                    </tr>
                  </table>
                  <%end if%>
                  </td>
                </tr>
                <tr>
                  <td colspan="4">&nbsp;</td>
                </tr>
              </table>
              <br>
  <%
RShotbilleder.MoveNext
loop
end if
%><br>
  <a href="upload.asp?id=<%=session("id")%>" onclick="NewWindow(this.href,'Copyright','450','150','no','center');return false">Tilføj nyt hot billede</a></td></tr>
      </table>
    </td>
    <td width="103" align="right" valign="top"><!--#include virtual="/right.asp"--></td>
  </tr>
</table>
<!--#include virtual="/bottom.asp"-->
Avatar billede montago Praktikant
13. april 2004 - 18:35 #52
prøv at smide den her ind...:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
site = "profil"
subsite = "profilhotbilleder"
%>
<!--#include virtual="/includeall.asp"-->
<!--#include virtual="/top.asp"-->
<!--#include virtual="/secure/access.asp"-->
<script language="javascript" type="text/javascript">
<!-- Centrering af pop-up vindue start
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// Centrering af pop-up vindue slut-->
</script>
<table width="772"  border="0" align="center" cellpadding="0" cellspacing="0" class="borderTop">
  <tr bgcolor="#FFFFFF">
    <td width="144" align="left" valign="top"><!--#include virtual="/left.asp"--></td>
    <td width="523" align="left" valign="top"><br>
      <br>
      <table width="448" height="134" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
          <tr>
            <td align="left" valign="top">
<%
    sqlfind="Select Count(*) as Found from hotbilleder where (profilerID = '" & Session("id") & "')"
    set RSfind = Conn.execute(sqlfind)
%>         
<%    if RSfind("Found") = "0" then    %>
      <br>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="2%">&nbsp;</td>
                  <td width="95%">                  Du har ikke tilf&oslash;jet nogle hot billeder...                </td>
                  <td width="3%">&nbsp;</td>
                </tr>
              </table>
<%     Else
'---- PLACERING DEL 1 START------
    Dim HotBillederArray(500,1)
    Dim PlaceringArr(500)
   
    strSQL1 = "SELECT DISTINCT hotbillederID FROM hotstemmer"
    Set DistinctSelection = Conn.Execute(strSQL1)
   
    do
        strSQL2 = "SELECT * FROM hotstemmer "
        strSQL2 = strSQL2 & " WHERE hotbillederID = " & DistinctSelection("hotbillederID") & ""
        Set SumSelection = Conn.Execute(strSQL2)
            do
                SumSelection_Sum = SumSelection_Sum + SumSelection("point")
            SumSelection.MoveNext
            loop while not SumSelection.EOF

        strSQL3 = "SELECT * FROM hotstemmer "
        strSQL3 = strSQL3 & " WHERE hotbillederID = " & DistinctSelection("hotbillederID") & ""
        Set NumSelection = Conn.Execute(strSQL3)
            do
                NumSelection_TotalRecords = NumSelection_TotalRecords + 1
            NumSelection.MoveNext
            Loop While not NumSelection.EOF
   
            Avarage = SumSelection_Sum / NumSelection_TotalRecords
        HotBillederArray(DistinctSelection("hotbillederID"),0) = DistinctSelection("hotbillederID")
        HotBillederArray(DistinctSelection("hotbillederID"),1) = Avarage
       
        NumSelection_TotalRecords = 0
        SumSelection_Sum = 0
    DistinctSelection.MoveNext
    loop while not DistinctSelection.EOF
'sortering
    For i = UBound(HotBillederArray) - 1  To 1 Step - 1
        MaxVal = HotBillederArray(i,1)
        MaxIndex = i
   
        For j = 0 To i
            If HotBillederArray(j,1) > MaxVal Then
                MaxVal = HotBillederArray(j,1)
                MaxIndex = j
            End If
        Next
   
        If MaxIndex < i Then
            HotBillederArray(MaxIndex,1) = HotBillederArray(i,1)
            HotBillederArray(MaxIndex,0) = HotBillederArray(i,0)
            HotBillederArray(i,1) = MaxVal
            HotBillederArray(i,0) = MaxVal
        End If
    Next
'Sortering Slut
'Læs det sorterede Array og sæt dem i en pæn orden
    For ReadArr = 0 to 500
        If HotBillederArray(ReadArr,1) <> "" then
            placering = placering + 1
            PlaceringArr(placering) = HotBillederArray(ReadArr,1)
        end if
    Next 
'---- PLACERING DEL 1 SLUT------

SQLhotbilleder = "select * from hotbilleder where profilerID = " & session("id")
set RShotbilleder = conn.execute(SQLhotbilleder)
    Do  'loop
%>
              <br>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr align="left" valign="top">
                  <td width="22%"><img src="/images/hotbilleder/thumb/<%=RShotbilleder("billede")%>" width="100"><br>
                    <a href="ret.asp?id=<%=RShotbilleder("id")%>" onclick="NewWindow(this.href,'Copyright','450','150','no','center');return false">Ret</a> - <a href="slet.asp?id=<%=RShotbilleder("id")%>" onclick="NewWindow(this.href,'Copyright','450','150','no','center');return false">Slet</a></td>
                  <td width="3%">&nbsp;</td>
                  <td width="41%">Tilf&oslash;jet: <%=DanskDatoTid(RShotbilleder("dato"))%><br>
Status:
  <%if RShotbilleder("godkendt") = "0" then%>
  <span style="color: #993333">Venter p&aring; godkendelse!</span>
  <%else%>
  <span style="color: #009900">Godkendt</span>
  <%end if

    SQLgen2 = "SELECT COUNT(*) AS count FROM hotstemmer where hotbillederID = " & RShotbilleder("id")&""
    Set RSgen2 = Conn.Execute(SQLgen2)
if not RSgen2("count") = "0" then   
    SQLgen1 = "SELECT SUM(point) FROM hotstemmer where hotbillederID = " & RShotbilleder("id")&""
    Set RSgen1 = Conn.Execute(SQLgen1)             
   
    gennemsnit = RSgen1(0)/RSgen2("count")
end if
%>
<br>
<%
    if not RSgen2("count") = "0" then
        Response.Write "Score: "
        Response.Write FormatNumber(gennemsnit,2)
        Response.Write "(" & RSgen2("count") & " stemmer)"
    Else
        Response.Write "Ingen stemmer!"
    End If
%><br>
<%
if not RSgen2("count") = "0" then
 
'---- PLACERING DEL 2 START------
        strSQL4 = "SELECT * FROM hotstemmer "
        strSQL4 = strSQL4 & "WHERE hotbillederID = " & RShotbilleder("id") & ""
        Set SumSelection2 = Conn.Execute(strSQL4)
            do
                SumSelection2_Sum = SumSelection2_Sum + SumSelection2("point")
                SumSelection2.MoveNext
            loop while not SumSelection2.EOF

        strSQL5 = "SELECT * FROM hotstemmer "
        strSQL5 = strSQL5 & " WHERE hotbillederID = " & RShotbilleder("id") & ""
        Set NumSelection2 = Conn.Execute(strSQL5)
            do
                NumSelection2_TotalRecords = NumSelection2_TotalRecords + 1
                NumSelection2.MoveNext
            Loop While not NumSelection2.EOF
   
            Avarage2 = SumSelection2_Sum / NumSelection2_TotalRecords
               
        For TotalPlacering = 0 to 500
            If PlaceringArr(TotalPlacering) = Avarage2 Then
                  Response.Write "Placering: " & TotalPlacering & ": " & PlaceringArr(TotalPlacering) & " Point <br>"
                  Exit For
            end if
        Next
Else
    response.Write("MIN. 20 stemmer")
End if
'---- PLACERING DEL 2 SLUT------
%>
<br>
<br>
<a href="/default.asp?mode=picture&pictureID=<%=RShotbilleder("id")%>">Se billede</a><br>
<a href="/profil/hotbilleder/sestemmer/?id=<%=RShotbilleder("id")%>">Se stemmer</a> </td>
                  <td width="34%" valign="bottom">
                 
<%
    Sql = "SELECT count(*) as '0' FROM hotstemmer WHERE profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS0 = conn.execute(sql)
   
    if not RS0("0") = "0" then
    Sql = "SELECT count(*) as '1' FROM hotstemmer WHERE point = '1' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS1 = conn.execute(sql)
    Sql = "SELECT count(*) as '2' FROM hotstemmer WHERE point = '2' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS2 = conn.execute(sql)
    Sql = "SELECT count(*) as '3' FROM hotstemmer WHERE point = '3' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS3 = conn.execute(sql)
    Sql = "SELECT count(*) as '4' FROM hotstemmer WHERE point = '4' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS4 = conn.execute(sql)
    Sql = "SELECT count(*) as '5' FROM hotstemmer WHERE point = '5' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS5 = conn.execute(sql)
    Sql = "SELECT count(*) as '6' FROM hotstemmer WHERE point = '6' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS6 = conn.execute(sql)
    Sql = "SELECT count(*) as '7' FROM hotstemmer WHERE point = '7' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS7 = conn.execute(sql)
    Sql = "SELECT count(*) as '8' FROM hotstemmer WHERE point = '8' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS8 = conn.execute(sql)
    Sql = "SELECT count(*) as '9' FROM hotstemmer WHERE point = '9' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS9 = conn.execute(sql)
    Sql = "SELECT count(*) as '10' FROM hotstemmer WHERE point = '10' AND profilerID = "& session("id") &" AND hotbillederID = "& RShotbilleder("id") &""
    Set RS10 = conn.execute(sql)
   
    varTotal = RS0("0")
    varTalt1 = RS1("1")
    varTalt2 = RS2("2")
    varTalt3 = RS3("3")
    varTalt4 = RS4("4")
    varTalt5 = RS5("5")
    varTalt6 = RS6("6")
    varTalt7 = RS7("7")
    varTalt8 = RS8("8")
    varTalt9 = RS9("9")
    varTalt10 = RS10("10")
    ialt1 = varTalt1/varTotal*100
    ialt2 = varTalt2/varTotal*100
    ialt3 = varTalt3/varTotal*100
    ialt4 = varTalt4/varTotal*100
    ialt5 = varTalt5/varTotal*100
    ialt6 = varTalt6/varTotal*100
    ialt7 = varTalt7/varTotal*100
    ialt8 = varTalt8/varTotal*100
    ialt9 = varTalt9/varTotal*100
    ialt10 = varTalt10/varTotal*100
%>                 
                 
                  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr align="center" valign="bottom">
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt1,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt2,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt3,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt4,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt5,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt6,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt7,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt8,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt9,0)%>"></td>
                      <td width="10%"><img src="/images/statistik.jpg" width="7" height="<%= Round(ialt10,0)%>"></td>
                    </tr>
                    <tr align="center" valign="top">
                      <td>1</td>
                      <td>2</td>
                      <td>3</td>
                      <td>4</td>
                      <td>5</td>
                      <td>6</td>
                      <td>7</td>
                      <td>8</td>
                      <td>9</td>
                      <td>10</td>
                    </tr>
                  </table>
                  <%end if%>
                  </td>
                </tr>
                <tr>
                  <td colspan="4">&nbsp;</td>
                </tr>
              </table>
              <br>
<%
    RShotbilleder.MoveNext
    Loop while not RShotbilleder.EOF
End if
%><br>
  <a href="upload.asp?id=<%=session("id")%>" onclick="NewWindow(this.href,'Copyright','450','150','no','center');return false">Tilføj nyt hot billede</a></td></tr>
      </table>
    </td>
    <td width="103" align="right" valign="top"><!--#include virtual="/right.asp"--></td>
  </tr>
</table>
<!--#include virtual="/bottom.asp"-->
Avatar billede tzag_dk Nybegynder
13. april 2004 - 21:30 #53
Det virker desværre heller ikke :-(
Jeg kan ikke se hvorfor at den ikke at lyst til at tage placering med i denne loop.
Avatar billede montago Praktikant
13. april 2004 - 21:56 #54
hmm næ... men er der nok stemmer til at de bliver vist ?? der kræves jo 20
Avatar billede tzag_dk Nybegynder
13. april 2004 - 22:40 #55
Ja det er der for den count som der bestemmer det, er sat til: if not RSgen2("count") = "0" then

så jeg fatter det bare ikke, har sidet og kikket koden igennem igen og igen. Og kan bare ikke se hvorfor at den ikke gør det.
Avatar billede montago Praktikant
13. april 2004 - 23:11 #56
ASP's veje er urandsagelige ?
Avatar billede tzag_dk Nybegynder
21. maj 2004 - 13:18 #57
hej montago

Jeg har ikke fået det til at virke, men smider du ikke et svar for din indsats?
Avatar billede tzag_dk Nybegynder
21. maj 2004 - 13:19 #58
Hov, det har du jo gjort :-)

LUKKET!
Avatar billede montago Praktikant
21. juni 2004 - 14:24 #59
Select hotbillederID,SUM(POINT) from HotStemmer group by hotbillederID order by count(POINT) desc

SÅDAN... MUHAHA

det er den SQL du skal bruge !
Avatar billede montago Praktikant
21. juni 2004 - 14:25 #60
jeg laver det færdige svar til dig senere
Avatar billede montago Praktikant
21. juni 2004 - 14:29 #61
du laver denne her:

set RS = conn.execute("Select hotbillederID,SUM(POINT) from HotStemmer group by hotbillederID order by count(POINT) desc
")

Do while not rs.eof
  placering = placering + 1
  if rs("hotbillederID") = "den du vil undersøge" then
    response.write placering & "alt det andet gejl"
  end if
loop

hvis du har brug for flere data er det intet problem !!
Avatar billede tzag_dk Nybegynder
21. juni 2004 - 15:13 #62
Hej igen
Du kan få resten af dine point her :-)
http://www.eksperten.dk/spm/512241

Tak for hjælpen :o)
Avatar billede montago Praktikant
21. juni 2004 - 17:39 #63
hehe... sad og rodede med SQL her i dag-.. og kom i tanke om dit problem...

så jeg tænkte jeg ville hjælpe... selvom det er langt tid siden ;-)
Avatar billede tzag_dk Nybegynder
21. juni 2004 - 23:32 #64
Ja, det er da lidt tid siden :-) hehe
Jeg fik løst det ved at få lavet en funktion.
Men jeg syntes at det er kanon at du lavede det selv om at spm´et var lukket! :o)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester