<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString="DRIVER={MySQL ODBC 3.51 Driver};SERVER=XXXXXXXXXXXXXXX;PORT=3306;DATABASE= XXXXXXXX; USER=XXXXXX;PASSWORD=XXXXXXXXX;OPTION=3;"
cn.open
periodo2="2012-03"
Dim rs9, sql9
Set rs9 = Server.CreateObject("ADODB.Recordset")
sql9 = "SELECT * FROM ordini WHERE data LIKE '%"&periodo2&"%' order by data desc"
'sql9 = "SELECT sum(quantita) as qta FROM ordini WHERE id_prodotto='"&prod&"' and data LIKE '%"&periodo2&"%' ORDER BY 1 DESC"
Set rs9.ActiveConnection = cn
rs9.CursorType = 1
rs9.LockType = 3
rs9.CursorLocation = 2
rs9.Open sql9, cn
do until rs9.eof
prod=rs9("id_prodotto")
Dim rs, sql
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM ordini WHERE id_prodotto='"&prod&"' and data LIKE '%"&periodo2&"%' ORDER BY 1 DESC"
'sql = "SELECT sum(quantita) as qta FROM ordini WHERE id_prodotto='"&prod&"' and data LIKE '%"&periodo2&"%' ORDER BY 1 DESC"
Set rs.ActiveConnection = cn
rs.CursorType = 1
rs.LockType = 3
rs.CursorLocation = 2
rs.Open sql, cn
conteggio=0
do until rs.eof
qut=rs("quantita")
conteggio=conteggio+qut
rs.movenext
loop
%>
<%=rs9("prodotto")%> - <%=conteggio%>
<%
rs9.movenext
loop
rs.close
set rs=nothing
rs9.close
set rs9=nothing
%>
problema: io devo ordinare i prodotti stampati per quantità data da CONTEGGIO
![]()