Hola a todos,
Estoy haciendo una web bastante básica de un videoclub y en un rincón de la web he puesto una imagen aleatoria que elige entre una de las caratulas que tengo. Quizás debería obtenerla de mi base de satos pero al no tener muchas fotos aún (260) obtengo la foto de la carpeta de caratulas. El problema que tengo ahora es que quiero que esta imagen sea un link a la ficha de esa peli, el problema es que tal y como lo tengo ahora me coge el nombre de la imagen entera, por ejemplo: 06.jpg y yo quiero quitar el .jpg para que me funcione el hipervínculo. Os pongo el código de esa parte por si me podéis ayudar.
Código PHP:
<span class="lrecomendacion">Quizá le interese...</span>
<a href="../detalle.asp?id=<%=RandomImage("caratulas/","caratulas/01.jpg")%>">
<img class="recomendacion" src="<%=RandomImage("caratulas/","caratulas/01.jpg")%>"/></a>
RandomImage está incluido en RandomTest.inc.asp que es este archivo:
Código PHP:
<%
Function RandomImage(strPath,strDefault)
On Error Resume Next
Randomize Timer
' declare all variables
Dim objFSO, objFolder, objFiles, objFile
Dim strFiles, strImages, strPhysical, strFile
' this constant has the names of valid image file name
' extensions and can be modified for more image types
Const strValid = ".gif.jpg.png"
' make sure we have a trailing slash in the path
If Right(strPath,1) <> Chr(47) Then strPath = strPath & Chr(47)
' get the physical path of the folder
strPhysical = Server.MapPath(strPath)
' get a File System Object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' create a folder object
Set objFolder = objFSO.GetFolder(strPhysical)
' get the files collection
Set objFiles = objFolder.Files
' enumerate the files collection looking for images
For Each objFile in objFiles
strFile = LCase(objFile.Name)
If Instr(strValid,Right(strFile,4)) Then
' add vaild images to a string of image names
strFiles = strFiles & strFile & vbTab
End If
Next
' split the image names into an array
strImages = Split(strFiles,vbTab)
' if we have an array...
If UBound(strImages) > 1 Then
' get a random name
RandomImage = strPath & strImages(Int(Rnd(1)*UBound(strImages)))
Else
' otherwise return the default
RandomImage = strDefault
End If
End Function
%>
El problema que tengo es que obtengo una imagen, por ejemplo:
<img src="caratulas/01.jpg>
pero el hípervinculo que creo es:
http://localhost/pelis2/detalle.asp?id=caratulas/01.jpg
y yo necesito que sea:
http://localhost/pelis2/detalle.asp?id=01
¿Cómo puedo separar el 01 o el número que sea de lo que consigo con esa función?
Si pueden darme cualquier consejo se lo agradecería mucho.