-
E' il mio primo post un saluto a tutti.
Ho provato a cercare un post sull'argomento senza risultati.
Dovrei gestire una classifica di un campionato di basket.
Ho creato il database e le pagine per modificarlo.
Il problema è che no riesco ad ordinare i record in base ai punti in classifica.potete aiutarmi?
Grazie anticipatamente
rubin
-
Ciao e benvenuto rubin

Dovresti fare una query del genere:
"SELECT squadra, SUM(punti) AS puntiTot FROM classifica GROUP BY squadra ORDER BY puntiTot DESC"Però sto solo ipotizzando la tabella che stai utilizzando... magari se ci dai più info è meglio


-
GRAZIE MADAI

il database è semplice:
nome campo
SQUADRA (testo)
P (Numerico)ho creato questo... dov'è lerrore? Cioè funziona tutto però non mette tutto in ordine di punti in classifica
<%
else
select case Request.querystring("Action")
case "Cancella"
Conn.Execute Request.querystring("Query")
Response.Redirect "classifica2006-07.asp?Tabella=" & TabellaDaVisualizzare & "&TOP=" & clng(Request.QueryString ("TOP"))
case "Aggiorna"
rs.Open "SELECT * FROM " & TabellaDaVisualizzare & " " & Request.querystring("Query") &" order by asc ",conn,1,3
set mNew = mtable.tables(TabellaDaVisualizzare)%>
-
Visto che nel campo p hai già i punti totali la query è molto più semplice, devi solo ordinare il recordset per p DESC:
"... ORDER BY p DESC"
FAI ATTENZIONE, vedo che passi la query sql via querystring il che è molto pericoloso!!! Sai cosa succederebbe se passassi Query=;DELETE * FROM tabella? Prova ad immaginare!
-
-
Invece della stringa in grassetto devi mettere " ORDER BY p DESC"
<% else select case Request.querystring("Action") case "Cancella" Conn.Execute Request.querystring("Query") Response.Redirect "classifica2006-07.asp?Tabella=" & TabellaDaVisualizzare & "&TOP=" & clng(Request.QueryString ("TOP")) case "Aggiorna" rs.Open "SELECT * FROM " & TabellaDaVisualizzare & " " & Request.querystring("Query") &" [B]order by asc [/B]",conn,1,3 set mNew = mtable.tables(TabellaDaVisualizzare) %>anche se ti funzionasse occhio alla mia avvertenza: passare la query via querystring è molto pericoloso. Passa invece dei parametri in base ai quali costruire la query:
Es:
q = Request("q") If q = "x" then queryString = "SELECT ..." ElseIf q = "y" then queryString = "SELECT ..." Else Response.Write("ERRORE") End if
-
-
-
non si ordina...
io utilizzo un selezionatore che mi permettrebbe di gestirre più classifiche.
Lo trovi quise facessi leggere direttamente il database?
-
-
Eccola... ho provato così anche prima... sono fuso

<%
Function Apex(sData,newData)
' Return string with single quotes doubledDim iLast As Integer
If Len(sData) = 0 Then
NewData = ""
Exit Function
END IF
iLast = InStr(sData, "'")
While iLast
sPart = sPart & left(sData, iLast - 1) & "'" & "'"
sData = Right(sData, Len(sData) - iLast)
iLast = InStr(sData, "'")
Wend
sData = sPart & sData
newData = Trim(sData)
End Function'Create object. In this case Connection to a database
Set Conn = Server.CreateObject("ADODB.Connection")
'Select provider
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
'Select data source.
'Server.MapPath function is equivalent to app.path function of VB
'It returns the directory in which the script is present
Conn.ConnectionString = "Data Source=" & Server.MapPath ("classifica.mdb")
'Open the connection
Conn.Open'Create recordset
Set Rs = Server.CreateObject("ADODB.Recordset")
Set mTable = Server.CreateObject("ADOX.Catalog")
set mNew = Server.CreateObject("ADOX.Table")
'Open recordset with the connection which we have created earlier
'you must be familiar with SELECT statement ,
'If not check my VB tutorial section.
mtable.ActiveConnection = Conn.ConnectionString
TabellaDaVisualizzare = Request.querystring("Tabella")
if TabellaDaVisualizzare = "" then
TabellaDaVisualizzare = Request.form("Tabella")
end if
SQL =Request.querystring("sSQL")sql = "SELECT * FROM classifica ORDER BY p DESC"
%>
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi