Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 22
  1. #1

    Link su immagine da database

    Buongiorno a tutti. Questo file interroga un database e restituisce risultati tra i quali un'immagine.
    Vorrei sapere se è possibile che su ogni immagine dei risultati ottenuti fosse possibile cliccare e rimandare ad un link specifico.

    <%@ Language=VBScript %>


    <%
    Option Explicit
    Response.Buffer = True 'Turn buffering on
    Response.Expires = -1 'Page expires immediately
    ' Response.Write ("CATEGORIA= "&Request("CATEGORIA"))

    'Constants
    Const MIN_PAGESIZE = 5 'Minimum pagesize
    Const MAX_PAGESIZE = 20 '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

    'Create objects
    Set objCn = Server.CreateObject("ADODB.Connection")
    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

    '-Build dynamic sql
    sql = "SELECT ID, NOME, CATEGORIA, FIGURA FROM Tabella "

    '--ID (exact search only)
    If Not IsEmpty(Request("id")) Then
    If IsNumeric(Request("id")) Then
    'Add to query
    'First item so we don't have to test for WHERE
    blnWhere = True 'Set where to true
    sql = sql & "WHERE "
    sql = sql & "(ID = " & CStr(CLng(Request("id"))) & ") "
    End If
    End If

    '--NOME (partial and exact search)
    If Not IsEmpty(Request("NOME")) Then
    Dim strNOME
    strNOME = Trim(Request("NOME"))

    If strNOME <> "" Then
    'Test for WHERE
    If blnWhere Then sql = sql & "AND " Else sql = sql & "WHERE " : blnWhere = True

    If (Left(strNOME, 1) = "*" And Len(strNOME) > 1) Then 'Partial search
    sql = sql & "(NOME LIKE '%" & Replace(Mid(strNOME, 2), "'", "''") & "') "
    ElseIf (Right(strNOME, 1) = "*" And Len(strNOME) > 1) Then 'Partial search
    sql = sql & "(NOME LIKE '" & Replace(Mid(strNOME, 1, Len(strNOME)-1), "'", "''") & "%') "
    Else 'Exact match
    sql = sql & "(NOME = '" & Replace(strNOME, "'", "''") & "') "
    End If

    End If
    End If

    '--CATEGORIA (partial and exact search)
    If Not IsEmpty(Request("CATEGORIA")) Then
    Dim strCATEGORIA
    strCATEGORIA = Trim(Request("CATEGORIA"))

    If strCATEGORIA <> "" Then
    'Test for WHERE
    If blnWhere Then sql = sql & "AND " Else sql = sql & "WHERE " : blnWhere = True

    If (Left(strCATEGORIA, 1) = "*" And Len(strCATEGORIA) > 1) Then 'Partial search
    sql = sql & "(CATEGORIA LIKE '%" & Replace(Mid(strCATEGORIA, 2), "'", "''") & "') "
    ElseIf (Right(strCATEGORIA, 1) = "*" And Len(strCATEGORIA) > 1) Then 'Partial search
    sql = sql & "(CATEGORIA LIKE '" & Replace(Mid(strCATEGORIA, 1, Len(strCATEGORIA)-1), "'", "''") & "%') "
    Else 'Exact match
    sql = sql & "(CATEGORIA = '" & Replace(strCATEGORIA, "'", "''") & "') "
    End If

    End If
    End If


    '--Dynamic sql finished

    'Create and open connection object
    With objCn
    .CursorLocation = adUseClient
    .ConnectionTimeout = 15
    .CommandTimeout = 30
    .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("DBASE/DATABASE.mdb") & ";"
    .Open
    End With

    'Create and open recordset object
    With objRs
    .ActiveConnection = objCn
    .CursorLocation = adUseClient
    .CursorType = adOpenForwardOnly
    .LockType = adLockReadOnly
    .Source = sql
    .PageSize = intPageSize
    .Open
    Set .ActiveConnection = Nothing 'Disconnect the recordset
    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 = "End Of Hits"
    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 = "Page " & intPage & " of " & intPageCount & ": "

    If intPage <> 1 Then
    strRet = strRet & "&lt;&lt;Prev "
    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 & " Next>> "
    End If
    End If

    Paging = strRet
    End Function
    %>

    <html>
    <head>
    <title>Ricerca su Database</title>
    <style>
    BODY
    {
    FONT-WEIGHT: normal;
    FONT-SIZE: 9pt;
    COLOR: black;
    FONT-FAMILY: Arial, Helvetica, sans-serif;
    TEXT-DECORATION: none
    }
    TABLE
    {
    FONT-WEIGHT: normal;
    FONT-SIZE: 9pt;
    COLOR: black;
    FONT-FAMILY: Arial, Helvetica, sans-serif;
    TEXT-DECORATION: none
    }
    A
    {
    FONT-WEIGHT: normal;
    FONT-SIZE: 9pt;
    COLOR: blue;
    FONT-FAMILY: Arial, Helvetica, sans-serif;
    TEXT-DECORATION: underline
    }
    HR
    {
    COLOR: #0072bc
    }
    </style>
    </head>

    <body onload="javascript: document.frmSearch.id.select();">

    <table border="0" width="100%" cellpadding="2" cellspacing="2">


    form name="frmSearch" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")% >">
    <input type="hidden" name="page" value="1">
    <tr>
    <td align=center>
    <table border="0" width="100%" cellpadding="2" cellspacing="2">
    <tr>
    <td colspan="2"><font size="3"><font color="#336699">Opzioni di ricerca nominativo</font></td>
    </tr>

    <tr>
    <td nowrap><u>I</u>D Nominativo:</td>
    <td width="100%"><input accesskey="i" type="text" name="id" size="10" value="<%=Server.HTMLEncode(Request("id"))%>">(Ric erca esatta)</td>
    </tr>

    <tr>
    <td nowrap><u>N</u>ome:</td>
    <td width="100%"><input accesskey="s" type="text" name="NOME" size="20" value="<%=Server.HTMLEncode(Request("NOME"))%>">(N ome)</td>
    </tr>

    <tr>
    <td nowrap><u>L</u>inee Per Pagina:</td>
    <td width="100%"><input accesskey="r" type="text" name="pagesize" size="10" value="<%=intPageSize%>"></td>
    </tr>
    <tr>
    <td colspan="2">
    <input type="button" name="btnRestart" value="Ricomincia" onclick="javascript: window.location='<%=Request.ServerVariables("SCRIP T_NAME")%>'">

    <input type="submit" name="btnSubmit" value="Go!">
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </form>
    <tr><td><hr></td></tr>

    <%If objRs.EOF Then%>

    <tr><td align="center"><font size="4">Nessun nominativo!</font></td></tr>

    <%Else%>

    <tr>
    <td>
    <table border="0" width="100%" cellpadding="3" cellspacing="3">
    <tr><td colspan=4>[b]Nominativi trovati: <%=objRs.RecordCount%></td></tr>
    <tr><td align="center" colspan="4"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td></tr>

    <tr bgcolor="#efefef">
    <td nowrap width="3%">ID</td>
    <td nowrap>Nome</td>
    <td nowrap>Categoria</td>
    <td nowrap>Figura</td>
    </tr>

    <%
    If objRs.PageCount < intPage Then intPage = objRs.PageCount
    objRs.AbsolutePage = intPage
    Dim strRowColor
    strRowColor = "#ffffff"
    Do While Not objRs.EOF And intRecord <= intPageSize
    %>

    <tr bgcolor="<%=strRowColor%>">
    <td nowrap><%=objRs("ID").Value%></td>
    <td nowrap><%=objRs("NOME").Value%></td>
    <td nowrap><%=objRs("CATEGORIA").Value%></td>
    <td><a href="images/prova.jpg">[img]<%=objRs([/img]" name="Image1">

    </tr>
    <%
    If strRowColor = "#ffffff" Then strRowColor = "#90ee90" Else strRowColor = "#ffffff"
    intRecord = intRecord + 1
    objRs.MoveNext
    Loop
    %>
    <tr><td colspan="4"><hr></td></tr>
    <tr><td align="center" colspan="4"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td></tr>
    </table>
    </td>
    </tr>

    <%End If%>
    </table>

    </body>
    </html>

    <%
    'Object cleanup
    If IsObject(objRs) Then
    If Not objRs Is Nothing Then
    If objRs.State = adStateOpen Then objRs.Close
    Set objRs = Nothing
    End If
    End If

    If IsObject(objCn) Then
    If Not objCn Is Nothing Then
    If objCn.State = adStateOpen Then objCn.Close
    Set objCn = Nothing
    End If
    End If
    %>

    Se uso <a href="images/123.jpg"> all'interno di : <td><a href="images/prova.jpg">[img]<%=objRs([/img]" name="Image1"> ogni immagine della ricerca va sullo stesso link.
    Potete aiutarmi ? Grazie. Antonella
    - las penas sirven por asustar a quines no desean cometer pecados -

  2. #2
    se non ho capito male prova così

    <a href=<%=objRs("FIGURA")%>>[img]<%=objRs([/img]" name="Image1">
    MEMENTO AUDERE SEMPER
    Maxxl

    www.maxxl.it

  3. #3
    Non funziona

    Scritto così :
    <td><a href="images/"+<%=objRs("FIGURA")%>>[img]<%=objRs([/img]" name="Image1">

    il risultato sono due immagini !
    - las penas sirven por asustar a quines no desean cometer pecados -

  4. #4
    MEMENTO AUDERE SEMPER
    Maxxl

    www.maxxl.it

  5. #5
    Ma se in testa alla pagina usi:

    codice:
    <%@ Language=VBScript %>
    usa la sintassi VBScript, quindi cambia:

    in:

    Provare paura per un qualcosa che ti possa capitare nel futuro non ti evita quell'evento,ti fa soltanto vivere un presente sbagliato!

  6. #6
    Anche così il risultato non cambia !
    - las penas sirven por asustar a quines no desean cometer pecados -

  7. #7
    ricordati di chiudere i TAG

    </a></td>
    MEMENTO AUDERE SEMPER
    Maxxl

    www.maxxl.it

  8. #8
    Era già prevista la chiusura....
    - las penas sirven por asustar a quines no desean cometer pecados -

  9. #9
    ma objRs("FIGURA") cosa è?(testo??) e cosa memorizzi in questo campo??
    MEMENTO AUDERE SEMPER
    Maxxl

    www.maxxl.it

  10. #10
    in questo campo viene memorizzato il testo (ad esempio 123.jpg) che va a prendere l'innagine corrispondente
    - las penas sirven por asustar a quines no desean cometer pecados -

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.