Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2009
    Messaggi
    10

    Motore di ricerca interno al sito.

    Vorrei creare un sito e ho registrato un account su Altervista e vorrei inserire nel mio sito un motore di ricerca inteno per questo sto facendo alcune prove.
    Cmq il problem è:

    Ho creato un database chiamato database.mdb, ho inserito una taballa chiamata documenti con i segienti campi: id, titolo, url, descrizione.

    Poi ho creato un file asp con il seguente script:

    <%@LANGUAGE = JScript%>
    <html>
    <head>
    <title>Cerca nel sito</title>
    </head>
    <body>

    <h3>Cerca nel sito</h3>

    <form method="POST" action="ricerca.asp?cerca=OK">
    <input type="text" name="stringa">
    <input type="submit" value="Cerca">
    </form>

    <%
    var cerca = new String(Request.QueryString("cerca"));
    var testo = new String(Request.Form("stringa"));
    var apice = testo.replace(/'/g,"''");
    var stringa = apice.split(" ");
    if (cerca == "OK")
    {
    if (testo == "" || testo == "undefined")
    {
    Response.Write("

    Inserire almeno una parola per effettuare una rcerca</p>");
    }
    else
    {
    var Cn = new ActiveXObject("ADODB.Connection");
    Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("database.mdb"));
    var sql = "SELECT * FROM documenti WHERE";
    for (var i=0; i<stringa.length; i++)
    {
    if (i > 0)
    {
    sql += " AND";
    }
    sql += " descrizione LIKE '%" + stringa[i] + "%'";
    }
    var Mostra = Cn.Execute(sql);
    if (Mostra.EOF)
    {
    Response.Write("

    Nessun risultato</p>");
    }
    else
    {
    while (!Mostra.EOF)
    {
    with (Response)
    {
    Write("

    ");
    Write("" +Mostra("titolo") + "
    ");
    Write(Mostra("descrizione"));
    Write("</p>");
    Mostra.MoveNext();
    }
    }
    }
    Cn.Close();
    }
    }
    %>

    </body>
    </html>

    Ho caricato tutto su dominio altervista ma le ricerche non me le fa!!! Ma mi carica una pagina con il codice java (praticamente non mi traduce il codice). (Ecco il link: http://yourecipes.altervista.org/ricerca.asp)
    Cosa sbaglio!!!!

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Il dominio, altervista non supporta asp ma php.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

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