Visualizzazione dei risultati da 1 a 10 su 10

Discussione: parametri URL

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30

    parametri URL

    Ciao a tutti...
    Ho creato un piccolo notoziario (uso Dreamweaver)
    Nella pagina "ScegliNews" appaiono i link che dovrebbero far aprire, poi, la pagina "News".
    Ho impostato i collegamenti ipertestuali dei link della pagina "ScegliNews" passando come parametri URL l'ID della tabella del DB e il recordset "rsLeggiNews" della pagina "News" viene "filtrato, appunto, dall'ID ricevuto...o almeno dovrebbe..
    Infatti qualsiasi link venga cliccato si apre sempre il primo record (ID 1)

    Vi posto il tutto:
    Pagina "ScegliNews"


    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

    <%
    var rsScegliNews = Server.CreateObject("ADODB.Recordset");
    rsScegliNews.ActiveConnection = MM_Conn_News_STRING;
    rsScegliNews.Source = "SELECT * FROM News ORDER BY data DESC";
    rsScegliNews.CursorType = 0;
    rsScegliNews.CursorLocation = 2;
    rsScegliNews.LockType = 1;
    rsScegliNews.Open();
    var rsScegliNews_numRows = 0;
    %>
    <%
    var Repeat1__numRows = -1;
    var Repeat1__index = 0;
    rsScegliNews_numRows += Repeat1__numRows;
    %>
    <%
    // *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    // set the record count
    var rsScegliNews_total = rsScegliNews.RecordCount;

    // set the number of rows displayed on this page
    if (rsScegliNews_numRows < 0) { // if repeat region set to all records
    rsScegliNews_numRows = rsScegliNews_total;
    } else if (rsScegliNews_numRows == 0) { // if no repeat regions
    rsScegliNews_numRows = 1;
    }

    // set the first and last displayed record
    var rsScegliNews_first = 1;
    var rsScegliNews_last = rsScegliNews_first + rsScegliNews_numRows - 1;

    // if we have the correct record count, check the other stats
    if (rsScegliNews_total != -1) {
    rsScegliNews_numRows = Math.min(rsScegliNews_numRows, rsScegliNews_total);
    rsScegliNews_first = Math.min(rsScegliNews_first, rsScegliNews_total);
    rsScegliNews_last = Math.min(rsScegliNews_last, rsScegliNews_total);
    }
    %>

    <%
    // *** Recordset Stats: if we don't know the record count, manually count them

    if (rsScegliNews_total == -1) {

    // count the total records by iterating through the recordset
    for (rsScegliNews_total=0; !rsScegliNews.EOF; rsScegliNews.MoveNext()) {
    rsScegliNews_total++;
    }

    // reset the cursor to the beginning
    if (rsScegliNews.CursorType > 0) {
    if (!rsScegliNews.BOF) rsScegliNews.MoveFirst();
    } else {
    rsScegliNews.Requery();
    }

    // set the number of rows displayed on this page
    if (rsScegliNews_numRows < 0 || rsScegliNews_numRows > rsScegliNews_total) {
    rsScegliNews_numRows = rsScegliNews_total;
    }

    // set the first and last displayed record
    rsScegliNews_last = Math.min(rsScegliNews_first + rsScegliNews_numRows - 1, rsScegliNews_total);
    rsScegliNews_first = Math.min(rsScegliNews_first, rsScegliNews_total);
    }
    %>

    <!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>
    <title>Pianeta Taxi News</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    <!--
    .Stile18 {color: #FFFFFF; font-weight: bold; font-size: x-large; font-family: Arial, Helvetica, sans-serif; }
    .Stile2 {font-size: 22px;
    color: #000066;
    font-family: Arial, Helvetica, sans-serif;
    }
    .Stile27 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    color: #000066;
    font-weight: bold;
    }
    body {
    background-color: #000066;
    }
    .Stile28 {color: #FFFFFF}
    -->
    </style>
    </head>

    <body>



    </p>
    <table width="900" border="2" align="center" cellspacing="0" bordercolor="#000066" bgcolor="#FFFFFF">
    <tr>
    <td width="459">[img]Logo.bmp[/img]</td>
    <td width="211"><div align="center">
    <p class="Stile2">News</p>
    </div></td>
    <td width="214"><object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="214" height="91">
    <param name="movie" value="Film.swf" />
    <param name="quality" value="high" />
    <embed src="Film.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="214" height="91"></embed>
    </object></td>
    </tr>
    <tr>
    <td colspan="3" class="Stile27"> <%=(rsScegliNews_total)%> articoli pubblicati</td>
    </tr>
    <tr>


    </p>
    <p class="Stile27"></p>
    <td height="5"></td>
    </tr>
    <% while ((Repeat1__numRows-- != 0) && (!rsScegliNews.EOF)) { %>
    <tr>
    <td height="30" colspan="3" class="Stile27">="><%=(rsScegliNews.Fields.Item("Titolo").Value )%></td>
    </tr>
    <%
    Repeat1__index++;
    rsScegliNews.MoveNext();
    }
    %>
    <tr>
    <td colspan="3"></td>
    </tr>
    <tr>
    <td colspan="3">
    <p class="Stile27"> </p>
    <p class="Stile27"></p></td>
    </tr>
    </table>



    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="33" height="33">
    <param name="movie" value="torna.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#000066" />
    <embed src="torna.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="33" height="33" bgcolor="#000066"></embed>
    </object>
    <span class="Stile28">Indietro
    </span></p>
    </body>
    </html>
    <%
    rsScegliNews.Close();
    %>

    Pagina "News"


    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

    <%
    var rsLeggiNews__MMColParam = "1";
    if (String(Request.QueryString("ID")) != "undefined" &&
    String(Request.QueryString("ID")) != "") {
    rsLeggiNews__MMColParam = String(Request.QueryString("ID"));
    }
    %>
    <%
    var rsLeggiNews = Server.CreateObject("ADODB.Recordset");
    rsLeggiNews.ActiveConnection = MM_Conn_News_STRING;
    rsLeggiNews.Source = "SELECT * FROM News WHERE ID = "+ rsLeggiNews__MMColParam.replace(/'/g, "''") + "";
    rsLeggiNews.CursorType = 0;
    rsLeggiNews.CursorLocation = 2;
    rsLeggiNews.LockType = 1;
    rsLeggiNews.Open();
    var rsLeggiNews_numRows = 0;
    %>
    <!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>
    <title>Pianeta Taxi News</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    <!--
    .Stile2 {font-size: 22px;
    color: #000066;
    font-family: Arial, Helvetica, sans-serif;
    }
    .Stile27 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    color: #000066;
    font-weight: bold;
    }
    body {
    background-color: #000066;
    }
    .Stile28 {color: #FFFFFF}
    .Stile29 {font-size: 15px; color: #000066; font-family: Arial, Helvetica, sans-serif;}
    -->
    </style>
    </head>

    <body>



    </p>
    <table width="900" border="2" align="center" cellspacing="0" bordercolor="#000066" bgcolor="#FFFFFF">
    <tr>
    <td width="459">[img]Logo.bmp[/img]</td>
    <td width="211"><div align="center">
    <p class="Stile2">News</p>
    </div></td>
    <td width="214"><object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="214" height="91">
    <param name="movie" value="Film.swf" />
    <param name="quality" value="high" />
    <embed src="Film.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="214" height="91"></embed>
    </object></td>
    </tr>
    <tr>
    <td colspan="3"></td>
    </tr>
    <tr>


    </p>
    <p class="Stile27"></p></td>
    </tr>
    <tr>
    <td colspan="3">
    <p class="Stile27"><%=(rsLeggiNews.Fields.Item("Titol o").Value)%>del <%=(rsLeggiNews.Fields.Item("data").Value)%></p>
    <p class="Stile29"><%=(rsLeggiNews.Fields.Item("Testo ").Value)%></p> </td>
    </tr>
    </table>



    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="33" height="33">
    <param name="movie" value="torna1.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#000066" />
    <embed src="torna1.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="33" height="33" bgcolor="#000066"></embed>
    </object>
    <span class="Stile28">Indietro
    </span></p>
    </body>
    </html>
    <%
    rsLeggiNews.Close();
    %>

    Qualcuno può dirmi dov'è la magagna?
    Grazie a tutti per l'attenzione..

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    C'ho messo un'ora ad interpretare questo ginepraio...
    codice:
    <td height="30" colspan="3" class="Stile27">="><%=(rsScegliNews.Fields.Item("Titolo").Value)%></td>
    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30

    Ciao Roby..

    .. e grazie..
    ...sì... quello è il collegamento ipertestuale alla pagina "News" ... ma l'inguacchio dov'è ? ..sono troppo tordo per vederlo... :rollo:
    ...e scusa per la perdita di tempo...

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    è in neretto... aguzza la vista...
    O te lo devo scrivere in rosso?!

    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30

    ...in effetti...

    ...bè ...sono un pò cecato... ... Ho aggiunto "ID=" come m'hai suggerito però il comportamento non è cambiato... forse non ho notato qualcosa?

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Nell'URL cosa leggi? Noti un diversi ID per ogni link che clicchi?

    Roby

  7. #7
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30
    ...sì..in effetti nell'Url l'ID varia a seconda del link...anche se poi viene visualizzato sempre lo stesso record...
    Che significa ?

  8. #8
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30
    ...aspetta.. un momento.. Quando ho provato a cliccare sui link avevo , nella pagina "News",

    <%
    var rsLeggiNews__MMColParam = "1";
    if (String(Request.QueryString("MM_ColParam")) != "undefined" &&
    String(Request.QueryString("MM_ColParam")) != "") {
    rsLeggiNews__MMColParam = String(Request.QueryString("MM_ColParam"));
    }
    %>

    Ho ripristinato come variabile quella preimpostata da DW e cioè


    <%
    var rsLeggiNews__MMColParam = "1";
    if (String(Request.QueryString("ID")) != "undefined" &&
    String(Request.QueryString("ID")) != "") {
    rsLeggiNews__MMColParam = String(Request.QueryString("ID"));
    }
    %>
    e così adesso , su due record presenti nel DB, il primo funge ma sul secondo dice

    Tipo di errore:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi (operatore mancante) nell'espressione della query 'ID = 2='.
    /pianeta/News.asp, line 18

  9. #9
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30
    ...anzi no.. non funge nemmeno il primo ..stesso errore ma "=1="

  10. #10
    Utente di HTML.it
    Registrato dal
    Sep 2008
    Messaggi
    30

    Risolto...

    ciao Roby... ho risolto...
    Come suggerito da te ho aggiunto "ID=" ma poi ho anche tolto il segno "=" prima degli apicetti di chiusura..


    a href="News.asp?ID=<%=(rsScegliNews.Fields.Item("ID ").Value)%>"</a>

    Tutto OK..
    Ciao e...grazie per l'aiuto

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.