Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Problemi mercatino

  1. #1
    Utente di HTML.it L'avatar di yro
    Registrato dal
    Sep 2003
    Messaggi
    2,916

    ancora problemi vol mio mercatino :disperazione:

    ciao a tutti, come da titolo ho ancora problemi con lo script che sto facendo:

    in pratica è un mercatino dell'usato che nella hompage ha una specie di vetrina nella quale mi mostra gli ultimi 8 articoli inseriti solo con foto e che scalano alla prima all'ottava in base all'ultimo post inserito!(praticamente è come un guestbook a categorie!) questo è lo script:

    codice:
    set rs = server.CreateObject("ADODB.Recordset")
    rs.open "SELECT offercat, MAX(id) FROM mercatino GROUP BY offercat ORDER BY 2 DESC ", Conn
    
    ' inizio tabella	
    response.Write"<div align='center'><table border='0' cellspacing='0' cellpadding='0'bordercolor='#000000' ><tr>"	
    
    
    max=2
    
    	do while not rs.EOF
    
    		sql = "SELECT *  FROM mercatino WHERE offercat = '"& rs("offercat") &"' ORDER BY id DESC"
    		set rsCat = conn.execute(sql)
    		
    		if rsCat("immagine")<>"" then
    		x=x+1
    
    'titolo messaggio
    titolo = rsCat("offercat")
    '.........................
    if x<9 then
    
    response.Write"<td width='15px'></td><td><table width='100%'
    border='1px'  cellspacing='0' cellpadding='0'
    bordercolor='#990000'><tr border='0'><td border='0'><a
    href=offerlistcat.asp?selectcat=" & titolo &"><img height='89'
    width='158' src=../../dati/public/mercatino/"&rsCat("IMMAGINE")&"
    border='0'></td>  </tr><tr><td bgcolor='#FAD145'><div
    align='center'><a href=offerlistcat.asp?selectcat=" & titolo
    &"><font size='2' color='#000000'>" & rsCat("offernome")
    &"</font></a></div></td></tr></table>
    </td><td width='10px'></td>"
    
    if x=max then
    max=max+2
    response.Write"<tr></tr>"
    end if
    end if
    end if
    		
    		set rsCat = nothing
    	rs.movenext
    	
    	loop
    	
    	response.Write"</tr></table></div>"
    	
    	
    	rs.close()
    	set rs = nothing
    	conn.close
    	set conn = nothing
    il problema è che se inserisco un post nella stessa categoria e senza immagine di uno che cè nella home, quello della home sparisce.

    spero mi abbiate capito! :master:
    E se avessi il dono della profezia e conoscessi tutti i misteri e tutta la scienza, e possedessi la pienezza della fede così da trasportare le montagne, ma non avessi la carità, non sono nulla.

  2. #2
    Utente di HTML.it L'avatar di yro
    Registrato dal
    Sep 2003
    Messaggi
    2,916
    con questo codice il risultato è giusto ma mi da un'errore:

    set rs = server.CreateObject("ADODB.Recordset")
    rs.open "SELECT offercat, MAX(id) FROM mercatino GROUP BY offercat ORDER BY 2 DESC ", Conn
    response.Write sql




    ' inizio tabella
    response.Write"<div align='center'><table border='0' cellspacing='0' cellpadding='0'bordercolor='#000000' ><tr>"


    max=2

    do while not rs.EOF

    sql = "SELECT * FROM mercatino WHERE (offercat = '"& rs("offercat") &"') AND immagine<>'' ORDER BY id DESC"
    set rsCat = conn.execute(sql)

    if rsCat("immagine")<> "" then
    x=x+1

    'titolo messaggio
    titolo = rsCat("offercat")


    if x<9 then

    response.Write"<td width='15px'></td><td><table width='100%'
    border='1px' cellspacing='0' cellpadding='0'
    bordercolor='#990000'><tr border='0'><td border='0'><a
    href=offerlistcat.asp?selectcat=" & titolo &"><img height='89'
    width='158' src=../../dati/public/mercatino/"&rsCat("IMMAGINE")&"
    border='0'></td> </tr><tr><td bgcolor='#FAD145'><div
    align='center'><a href=offerlistcat.asp?selectcat=" & titolo
    &"><font size='2' color='#000000'>" & rsCat("offernome")
    &"</font></a></div></td></tr></table>
    </td><td width='10px'></td>"
    if x=max then
    max=max+2
    response.Write"<tr></tr>"
    end if
    end if
    end if

    set rsCat = nothing
    rs.movenext

    loop

    response.Write"</tr></table></div>"


    rs.close()
    set rs = nothing



    conn.close
    set conn = nothing

    e l'errore è:

    error '80020009'
    Exception occurred
    E se avessi il dono della profezia e conoscessi tutti i misteri e tutta la scienza, e possedessi la pienezza della fede così da trasportare le montagne, ma non avessi la carità, non sono nulla.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.