Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Aiuto salvatemi il posto

    Ragazzi vi prego aiutatemi,premetto che non sono un programmatore asp l' mia specialità è la grafica e flash, il programmatore dell' azienda è in viaggio di nozze e mi ha rimasto nei casini ,il mio capo sapendo che conosco un poco l'asp mia ha doto il compito di finire un progetto ,mi è rimasto da fare solo un maledetto motore di ricerca , sono nel pallone,aiutatemi.
    ho questa pagina di visualizzazione annunci e dovrei fare un piccolo motore di ricerca per marca prezzo e anno, qualcuno di voi potrebbe inviarmi un script in base a questa pagina

    Ragazzi lo so vi chide troppo ma vi prego aiutatemi

    <%@ Language=VBScript %>


    <%

    Response.Buffer = True 'Turn buffering on
    Response.Expires = -1 'Page expires immediately

    'Constants
    Const MIN_PAGESIZE = 5 'Minimum pagesize
    Const MAX_PAGESIZE = 100 'Maximum pagesize
    Const DEF_PAGESIZE = 10 'Default pagesize

    'Variables
    Dim objCn 'ADO DB connection object
    Dim objRs 'ADO DB recordset object
    Dim blnWhere 'True/False for have WHERE in sql already
    Dim intRecord 'Current record for paging recordset
    Dim intPage 'Requested page
    Dim intPageSize 'Requested pagesize
    Dim sql 'Dynamic sql query string

    cn = Session("cnn")

    %>

    <%
    Set objRs = Server.CreateObject("ADODB.Recordset")

    'Set/initialize variables
    intRecord = 1
    blnWhere = False

    '-Get/set requested page
    intPage = MakeLong(Request("page"))
    If intPage < 1 Then intPage = 1

    '-Get/set requested pagesize
    If IsEmpty(Request("pagesize")) Then 'Set to default
    intPageSize = DEF_PAGESIZE
    Else
    intPageSize = MakeLong(Request("pagesize"))
    'Make sure it fits our min/max requirements
    If intPageSize < MIN_PAGESIZE Then
    intPageSize = MIN_PAGESIZE
    ElseIf intPageSize > MAX_PAGESIZE Then
    intPageSize = MAX_PAGESIZE
    End If
    End If

    sql = "SELECT DISTINCT tbAnnunciAutokm.idAnnuncioAuto, tbAnnunciAutokm.Marca, tbAnnunciAutokm.Modello, tbAnnunciAutokm.Allestimento, tbAnnunciAutokm.TipoAuto, tbAnnunciAutokm.Anno,"

    sql = sql & " tbAnnunciAutokm.Chilometri, tbAnnunciAutokm.Prezzo, tbMarcaAuto.idMarcaAuto, tbMarcaAuto.Descrizione,"
    sql = sql & " tbVersioneAuto.idVersioneAuto, tbVersioneAuto.Versione,tbTipoAutokm.Descrizione AS TAuto , tbAnno.Anno AS Anno FROM"
    sql = sql & " ((((tbAnnunciAutokm INNER JOIN tbMarcaAuto ON tbAnnunciAutokm.Marca = tbMarcaAuto.idMarcaAuto)"
    sql = sql & " INNER JOIN tbVersioneAuto ON tbAnnunciAutokm.Modello = tbVersioneAuto.idVersioneAuto)"
    sql = sql &" INNER JOIN tbTipoAutokm ON tbAnnunciAutokm.TipoAuto = tbTipoAutokm.idTipoAuto)"
    sql = sql & " INNER JOIN tbAnno ON tbAnnunciAutokm.Anno = tbAnno.idAnno)"
    sql = sql & " Order By tbMarcaAuto.Descrizione Asc"






    With objRs
    .ActiveConnection = cn
    .CursorType = adOpenKeyset
    .LockType = adLockPessimistic
    .Source = sql
    .PageSize = intPageSize
    .Open
    End With

    'Creates a long value from a variant, invalid always set to zero
    Function MakeLong(ByVal varValue)
    If IsNumeric(varValue) Then
    MakeLong = CLng(varValue)
    Else
    MakeLong = 0
    End If
    End Function

    'Returns a neatly made paging string, automatically configuring for request
    'variables, regardless of in querystring or from form, adjust output to your needs.
    Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
    Dim strQueryString
    Dim strScript
    Dim intStart
    Dim intEnd
    Dim strRet
    Dim i

    If intPage > intPageCount Then
    intPage = intPageCount
    ElseIf intPage < 1 Then
    intPage = 1
    End If

    If intRecordCount = 0 Then
    strRet = "No Records Found"
    ElseIf intPageCount = 1 Then
    strRet = "***"
    Else
    For i = 1 To Request.QueryString.Count
    If LCase(Request.QueryString.Key(i)) <> "page" Then
    strQueryString = strQueryString & "&"
    strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "="
    strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
    End If
    Next

    For i = 1 To Request.Form.Count
    If LCase(Request.Form.Key(i)) <> "page" Then
    strQueryString = strQueryString & "&"
    strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "="
    strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
    End If
    Next

    If Len(strQueryString) <> 0 Then
    strQueryString = "?" & Mid(strQueryString, 2) & "&"
    Else
    strQueryString = "?"
    End If

    strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString

    If intPage <= 10 Then
    intStart = 1
    Else
    If (intPage Mod 10) = 0 Then
    intStart = intPage - 9
    Else
    intStart = intPage - (intPage Mod 10) + 1
    End If
    End If

    intEnd = intStart + 9
    If intEnd > intPageCount Then intEnd = intPageCount

    strRet = "Pagina " & intPage & " di " & intPageCount & ": "

    If intPage <> 1 Then
    strRet = strRet & "&lt;&lt;Precedente "
    End If

    For i = intStart To intEnd
    If i = intPage Then
    strRet = strRet & "" & i & " "
    Else
    strRet = strRet & "" & i & ""
    If i <> intEnd Then strRet = strRet & " "
    End If
    Next

    If intPage <> intPageCount Then
    strRet = strRet & " Successiva&gt;&gt; "
    End If
    End If

    Paging = strRet
    End Function

    %>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <SCRIPT language=JavaScript id=code>
    <!--
    function swapDisplay() {
    // Make sure a child element exists
    var child = event.srcElement.getAttribute("child");
    if (null!=child) {
    var el = document.all[child]
    if (null!=el)
    el.style.display = ""==el.style.display ? "block" : ""
    }
    }
    document.onclick = swapDisplay;
    // -->
    </SCRIPT>

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function go(loc) {
    window.location.href = loc;
    }
    // End -->
    </script>
    <title>Parco Auto</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="auto.css" rel="stylesheet" type="text/css">
    </head>

    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

    <div align="center">
    <table width="700" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td height="30" colspan="3" valign="top"></td>
    </tr>
    <tr>
    <td width="4" valign="top"></td>
    <td width="752"><div align="center">
    <table width="100%" border=0 cellpadding=0 cellspacing=0 id="Table1">
    <tr>
    <td colspan=8><table width="100%" height="23" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" class="txt" style="border-collapse: collapse">
    <tr>
    <td><table width="100%" border="0" cellspacing="5" cellpadding="5">
    <tr>
    <td><div align="center">Il Nostro Parco Auto Usate </div></td>
    </tr>
    </table>
    <div align="center">
    <%If objRs.EOF Then%>
    Nessun Annuncio Presente!
    <%Else%>

    Annunci Presenti: <%=objRs.RecordCount%>
    </div></td>
    </tr>
    </table>
    _ <table width="700" border="0" cellpadding=4 cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-collapse: collapse">
    <tr>
    <td width="10%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Marca
    </font></div></td>
    <td width="12%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Modello
    </font></div></td>
    <td width="10%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Tipo
    Auto </font></div></td>
    <td width="9%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Anno
    </font></div></td>
    <td width="6%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Km
    </font></div></td>
    <td width="10%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Prezzo</font></div></td>
    <td width="8%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Dettagli
    </font></div></td>
    <td width="22%" class="LineBottomUpBck"><div align="center"><font color="#FFFFFF">Foto</font></div></td>
    </tr>
    <%

    If objRs.PageCount < intPage Then intPage = objRs.PageCount
    objRs.AbsolutePage = intPage

    Do While Not objRs.EOF And intRecord <= intPageSize

    %>

    <td nowrap class="LineBottom2"><div align="center"><%=objRs("Descrizione").Value%></div></td>
    <td nowrap class="LineBottom2"><div align="center"><%=objRs("Versione").Value%><%=objRs("Allestimento").Value%></div></td>
    <td nowrap class="LineBottom2"><div align="center"><%=objRs("TAuto").Value%></div></td>
    <td nowrap class="LineBottom2"><div align="center"><%=objRs("Anno").Value%></div></td>
    <td nowrap class="LineBottom2"><div align="center"><%=objRs("Chilometri").Value%></div></td>
    <td nowrap class="LineBottom2"><div align="center">€<%=objRs("Prezzo").Value%></div></td>
    <td nowrap class="LineBottom2"><div align="center">">Visualizza</div></td>

    <%

    Dim lngImageID

    lngImageID = 0

    Set rsFotoAuto = Server.CreateObject("ADODB.Recordset")

    querystr = ""
    querystr = "SELECT * "
    querystr = querystr & "FROM tbFotoAuto "
    querystr = querystr & "WHERE tbFotoAuto.idAnnuncioAuto = " & objRs("idAnnuncioAuto")

    rsFotoAuto.ActiveConnection = cn
    rsFotoAuto.CursorType = adOpenKeyset
    rsFotoAuto.LockType = adLockOptimistic
    rsFotoAuto.Source = querystr
    rsFotoAuto.Open
    IF Not rsFotoAuto.EOF Then
    lngImageID = rsFotoAuto.Fields("idFotoAuto")
    End IF
    rsFotoAuto.Close

    %>

    <% if lngImageID > 0 Then %>
    <td class="LineBottom2"><div align="center"><img src= "image.asp?ImageID=<%=lngImageID%>" alt="Foto Auto" width="60" border="1" class="darkblueborder"></div></td>
    <% Else %>
    <td width="23%" align="center" class="LineBottom2">[img]nofoto.jpg[/img]</td>
    <% End If %>
    </tr>
    <%
    intRecord = intRecord + 1
    objRs.MoveNext
    Loop

    %>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%">
    <tr height="23">
    <td align="center"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td>
    </tr>
    <%
    End If%>
    </table></td>
    </tr>
    </table>
    </div></td>
    <td width="4" valign="top"><div align="center"></div>
    <div align="center"></div></td>
    </tr>
    <tr>
    <td height="30" colspan="3"><div align="center"><a href="parco.htm">Torna
    al Parco Auto
    </a></div></td>
    </tr>
    </table>
    </div>

    </body>
    </html>

  2. #2
    Con tanto codice ci si scrive un sistema operativo, non un motorino di ricerca interno

    Non ho modo di dargli un occhio e mettermelo a testare, ma se mi dici i campi della tabella su cui fa la ricerca e mi spieghi bene l'esigenza posso farti una breve analisi della cosa, in modo che tu possa usare delle linee guida per farlo da te.

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.