[Resolvido] Listar resultados de uma consulta separando por virgu
E ae galera!
Uso o seguinte código para montar um gráfico:
<%
'NÃO É OBRIGATORIO A MUDANÇA DE NENHUMA LINHA A PARTIR DESTE PONTO
Function makechart(title, numarray, labelarray, imagename, maxheight, maxwidth, addvalues)
dim tablestring
dim max
dim tempnumarray
dim templabelarray
dim heightarray
dim tempnum
if maxheight > 0 and maxwidth > 0 and ubound(labelarray) = ubound(numarray) then
templabelarray = labelarray
tempnumarray = numarray
heightarray = array()
max = 0
maxlength = 0
tablestring = "<TABLE border='1' bordercolor='#000000' width='400px'>" & vbCrLf
for each stuff in tempnumarray
if stuff > max then max = stuff end if
next
tempnum = maxheight/max
for counter = 0 to ubound(tempnumarray)
if tempnumarray(counter) = max then
redim preserve heightarray(counter)
heightarray(counter) = maxheight
else
redim preserve heightarray(counter)
heightarray(counter) = tempnumarray(counter) * tempnum
end if
next
tablestring = tablestring & "<TR bgcolor='#f5f5f5'><TH class=texto colspan='" & ubound(tempnumarray)+1 & "'>" & title & "</TH></TR>" & _
vbCrLf & "<TR bordercolor='#FFFFFF' class=texto>" & vbCrLf
for counter = 0 to ubound(tempnumarray)
tablestring = tablestring & vbTab & "<TD valign='bottom' align='center'><img src='" & imagename & "' width='" & maxwidth & "' height='" & _
heightarray(counter) & "'>"
if addvalues then
tablestring = tablestring & "<BR>" & tempnumarray(counter)
end if
tablestring = tablestring & "</TD>" & vbCrLf
next
tablestring = tablestring & "</TR>" & vbCrLf
for each stuff in labelarray
tablestring = tablestring & vbTab & "<TD align='center' bordercolor='#FFFFFF' class=texto><B> " & stuff & " </TD>" & vbCrLf
next
tablestring = tablestring & "</TABLE>" & vbCrLf
makechart = tablestring
else
Response.Write "Erro! A altura e a largura devem ser maiores que zero (0), ou o número de títulos não é igual ao número de valores passados..."
end if
end function
%>
############### CODIGO QUE EXIBE O GRÁFICO #################
<%
'**CONFIGURAÇÔES********
' esta parte você coloca onde realmente deseja que o gráfico apareça em seu site...
dim stuff , labelstuff , titulo, imagem, altura, largura, valores
titulo = "Acessos Semanais" 'Define o nome do grafico
imagem = "css/grafico.gif" 'Imagem que o grafico ira usar para montar as barras, pode ser uma imagem de 1x1
altura = 100 'Altura maxima do grafico
largura = 10 'Largura maxima do grafico
valores = "True" 'Se verdadeiro apresenta os valores
[color="#ff0000"]stuff = Array(0,0,0,0,0,0,0)[/color] 'Aqui você deve passar os valores que o grafico ira apresentar
[color="#ff00ff"]labelstuff = Array("Dom","Seg","Ter","Qua","Qui","---","Sab")[/color] 'Aqui você deve passar uma legenda para os valores passados na linha acima, deve ter a mesma quantidade
Response.Write makechart(titulo, stuff, labelstuff, imagem, altura, largura, valores) 'Chama a função e passa os valores que você passou como parametro
'**FIM CONFIGURAÇÔES********
%>
O gráfico no meu caso é um sistema de estatisticas onde tenho a quantidade de acessos em cada dia gravados em um banco MySql. O que eu não estou conseguinte é colocar os resultados separados por vírgula nos devidos campos como nas linhas coloridas.
Eu tentei assim mansi nao deu certo:
<%
Set rstS = conn.execute("Select * from semana where codusuario="&session("id"))
if rstS.eof then
response.write ""
else
while not rstS.eof
'if c = "" then
'c = 0
'else
'c = cint(c) + cint(1)
'end if
'For c = 0 to 6 'then
resultado = rstS("acessos")&","
response.write resultado
rstS.moveNext
wend
End if
%>
pois o resultado ficaria com uma virgula sobrando ao final
Ex: 0,5,6,4,9,8,1,
Alguem pode me ajudar?
vlw
Discussão (5)
Carregando comentários...