Visualizzazione dei risultati da 1 a 7 su 7

Discussione: funzione visualizza

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2009
    Messaggi
    16

    funzione visualizza

    ciao a tutti, vi vorrei chiedere un aiuto,ho creato un sito per news in asp, adesso le news sono suddivisi per categorie, ho creato una funzione crea categoria, e una crea news quando crea la news visualizzo un elenco con tutte le categorie “create con crea categoria” fin qua tutto ok, adesso vorrei che nella home del sito esca il menu con tutte le categorie create ed quando vado per esempio nella categoria sport vedo tutte le news create con la categoria sport. Come devo fare? Grazie a tutti

  2. #2
    mah così su due piedi direi che in homepage devi stampare l'elenco delle categorie prendendole dal database, facendo per ogni categoria un link del tipo

    codice:
    show_news.asp?cat=XXXX
    dove al posto delle X c'è l'id della categoria. nella pagina show_news.asp ricavi l'id dalla querystring e fai una query per ricavarti tutte le news. da li stampi tutte le news a video nel modo che ritieni piu opportuno
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2009
    Messaggi
    16
    ciao grazie del consiglio, ho provato cosi ma da errore

    ADODB.Field error '80020009'

    Il record corrente corrisponde all'inizio o alla fine del file oppure è stato eliminato. Per eseguire l'operazione richiesta è necessario disporre di un record corrente.
    /leggi_news.asp riga 0

    metto il codice che uso
    pagina news.asp che stampa tutte le categorie inserite nella tabella categorie
    codice:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>News</title>
    <link href="css_news/news.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    
    <div id="container">
      <div id="header">
        <h1>Intestazione</h1>
      </div>
      <div id="sidebar_left">
        <h3>Contenuto sidebar1</h3>
        <ul>
        	[*]Home
           	[*]Arichivio News[/list]
      </div>
      <div id="mainContent">
        <h1> Contenuto principale</h1>
        
        
    <%
    ' PERCORSO DEL DATABASE'
    url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/news/mdb-database/db.mdb")
    Set Conn = Server.CreateObject("ADODB.Connection")
    conn.Open url_DB
    Set RecSet = Server.CreateObject("ADODB.Recordset")
    ' PRELEVA LE ULTIME 10 CATEGORIE DAL DATABASE (SE SONO PRESENTI)'
    SQL = "SELECT TOP 10 * FROM categorie ORDER BY ID DESC"
    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic
    ' CONTROLLA SE SONO PRESENTI CATEGORIE NEL DB'
    If RecSet.Eof = False Then
    %>
    
    
    
    <table border="0" cellpadding="0" cellspacing="0" width="34%">
    			<%
    				' VISUALIZZA LE PRIME 10 CATEGORIE
    					Do until RecSet.Eof
    			%>
    				<tr>
    					<td width="6%"><font face="Verdana" size="2">&gt;</font></td>
    					<td width="94%"><font face="Verdana" size="2">"><%=RecSet("categorias")%></font></td>
    				</tr>
    			<%
    				RecSet.Movenext
    				Loop
    			%>
    			</table>
    			<%
    				End IF
    				RecSet.Close
    				Conn.Close
    				Set Conn = Nothing
    				Set RecSet = Nothing
    			%>
    	
        </div>
    
        <br class="clearfloat" />
      
       
       
       
       
    </div>
    </body>
    </html>
    codice pagina leggi_news.asp

    codice:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Leggi News</title>
    <link href="css_news/news.css" rel="stylesheet" type="text/css" />
    <style type="text/css"> 
    </style>
    <![endif]-->
    </head>
    
    <body>
    
    
    
    <%
    ' RICHIEDE L'ID
    ID = Request("ID")
    ' SE NON E' STATO PASSATO UN VALORE VALIDO
    ' COME ID, IMPOSTA QUESTO AD UNO
    If not ISNumeric(ID) or Len(ID) = 0 Then
    ID = 1
    End IF
    ' SE L'ID E' UGUALE A ZERO
    ' LO IMPOSTA UGUALE A UNO
    IF ID = 0 Then
    ID = 1
    End IF
    ' PERCORSO DEL DATABASE
    url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/news/mdb-database/db.mdb")
    Set Conn = Server.CreateObject("ADODB.Connection")
    conn.Open url_DB
    Set RecSet = Server.CreateObject("ADODB.Recordset")
    
    
    SQL = "SELECT * FROM NEWS WHERE ID = " & Request.Querystring(id) &""
    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic
    If RecSet.Eof = False Then
    
    End IF
    
    %>
    
    <h2 class="error">Errore: Nessuna news presente!</h2>
    
    <div id="container">
      <div id="header">
        <h1>Intestazione</h1>
      </div>
      <div id="sidebar_left">
        <h3>Contenuto sidebar1</h3>
        <ul>
        	[*]Home
           	[*]Arichivio News[/list]
      </div>
      <div id="mainContent">
        <h1> Contenuto principale</h1>
        
        
        
    
    <font face="Verdana" size="4">&gt; <%=RecSet("titolo")%>
    </font>
    
    
    <font face="Verdana" size="4">Categoria: <%=RecSet("categoria")%>
    </font><font face="Verdana" size="2">di
    <%=RecSet("autore")%> - <%=RecSet("data")%></font></p>
    
    
    <font face="Verdana" size="2"><%=RecSet("contenuto")%></font></p>
    
    
    </p>
    <%
    Conn.Close
    Set Conn = Nothing
    Set RecSet = Nothing
    %>
        
    
        </div>
    	
        <br class="clearfloat" />
       <div id="footer">
        
    
    Piè di pagina
    </p>
      </div>
    </div>
    </body>
    </html>
    mi potete aiutare? prefavore
    grazie

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    ID = Request("cat")

    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2009
    Messaggi
    16
    Grazie Roby, ma che punto devo modificare in quel modo?
    ok ID = Request("cat") al posto di ID = Request("id")
    adesso ho errore

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

    [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi (operatore mancante) nell'espressione della query 'ID ='.

    /news/leggi_news.asp, riga 41
    nella riga 41 ho RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Cosa recuperi a fare ID se poi nella query lo recuperi di nuovo???

    SQL = "SELECT * FROM NEWS WHERE ID = " & id &""

    Roby

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2009
    Messaggi
    16
    in effetti mi sono perso
    provo ha spiegare quello che vorrei fare:
    nella home (news.asp)
    voglio visualizzare tutte le categorie salvate nel db nella tabella categorie stringa categorias
    e con collegamento alla pagina leggin_news.asp e fin qua funziona, .
    infatti vedo tutti le varie categorie per esem.
    sport, l'ultima ora ecc.
    adesso vorrei quando seleziono la categoria sport, mi invia alla pagina leggi_news.asp?cat=<%=RecSet("categorias")%>
    mi visualizza solo tutte le news "salvate nella tabella news" che hanno la parola sporta nella stringa categoria.
    se non sono stato chiaro lo spiego meglio
    grazie

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 © 2026 vBulletin Solutions, Inc. All rights reserved.