harris9999
asked on
List Folder Contents from Recordset instead of all Contents
I have an asset manager with a wysiwyg editor.
By default when it opens it lists all the contents of the assets folder.
I want it to only display the ones assigned to a specific user.
I've been trying to adjust it but been unsuccessful so far.
The code below is the code writes the asset manager.
I've been trying to set the 3rd line: set oFiles = oFolder.files to the values from my recordset.
oFolder is already pointing to the correct folder.
My rs is obtained by the following code:
set cn = server.createobject("ADODB .Connectio n")
cn.provider = application("strProvider")
cn.open application("strConGallery ")
strSQL="Select Imagename, Id From Images Where UserId =" & Session("UserId")
set rs=cn.execute(strSQL)
cn.close
set cn=nothing
Is what I'm wanting doable?
Full file is also attached. (renamed .txt from .asp)
By default when it opens it lists all the contents of the assets folder.
I want it to only display the ones assigned to a specific user.
I've been trying to adjust it but been unsuccessful so far.
The code below is the code writes the asset manager.
I've been trying to set the 3rd line: set oFiles = oFolder.files to the values from my recordset.
oFolder is already pointing to the correct folder.
My rs is obtained by the following code:
set cn = server.createobject("ADODB
cn.provider = application("strProvider")
cn.open application("strConGallery
strSQL="Select Imagename, Id From Images Where UserId =" & Session("UserId")
set rs=cn.execute(strSQL)
cn.close
set cn=nothing
Is what I'm wanting doable?
Full file is also attached. (renamed .txt from .asp)
function writeFileSelections()
set oFolder = oFSO.GetFolder(currFolder)
set oFiles = oFolder.files
nIndex=0
bFileFound=false
Response.Write "<div style='overflow:auto;height:222px;width:100%;margin-top:3px;margin-bottom:2px;'>" & VbCrLf
Response.Write "<table border=0 cellpadding=2 cellspacing=0 width=100% height=100% >" & VbCrLf
'Response.Write "<tr><td colspan=4 width='100%'><b>"&getTxt("Files")&"</b></td></tr>"
sColor = "#e7e7e7"
for each oFile in oFiles
'ffilter ~~~~~~~~~~
bDisplay=false
sExt=getExt(oFile.path)
if ffilter="flash" then
if LCase(sExt)="swf" then bDisplay=true
elseif ffilter="media" then
if LCase(sExt)="avi" or LCase(sExt)="wmv" or LCase(sExt)="mpg" or _
LCase(sExt)="mpeg" or LCase(sExt)="wav" or LCase(sExt)="wma" or _
LCase(sExt)="mid" or LCase(sExt)="mp3" then bDisplay=true
elseif ffilter="image" then
if LCase(sExt)="gif" or LCase(sExt)="jpg" or LCase(sExt)="png" then bDisplay=true
else 'all
bDisplay=true
end if
'~~~~~~~~~~~~~~~~~~
if bDisplay then
bFileFound=true
nIndex=nIndex+1
'server.MapPath(sBaseFolder)
'oFSO.GetFolder(server.MapPath(sBaseFolder))
' => sama. yg satu c:\.. yg lain C:\..
'response.Write oFile.path & " - " & oFSO.GetFolder(server.MapPath(sBaseFolder)) & "<br>"
if InStr(1,oFile.path,oFSO.GetFolder(server.MapPath(arrBaseFolder(0)))) <> 0 then
sBaseFolder_PhysicalPath = oFolder_base0.path 'folder terakhir tdk diikuti dgn / shg sFile_VirtualPath_UnderBaseFolder diawali dgn /
sBaseFolder = arrBaseFolder(0)
end if
if arrBaseFolder(1)<>"" then'NEW 2.4
if InStr(1,oFile.path,oFSO.GetFolder(server.MapPath(arrBaseFolder(1)))) <> 0 then
sBaseFolder_PhysicalPath = oFolder_base1.path 'folder terakhir tdk diikuti dgn / shg sFile_VirtualPath_UnderBaseFolder diawali dgn /
sBaseFolder = arrBaseFolder(1)
end if
end if
if arrBaseFolder(2)<>"" then'NEW 2.4
if InStr(1,oFile.path,oFSO.GetFolder(server.MapPath(arrBaseFolder(2)))) <> 0 then
sBaseFolder_PhysicalPath = oFolder_base2.path 'folder terakhir tdk diikuti dgn / shg sFile_VirtualPath_UnderBaseFolder diawali dgn /
sBaseFolder = arrBaseFolder(2)
end if
end if
if arrBaseFolder(3)<>"" then'NEW 2.4
if InStr(1,oFile.path,oFSO.GetFolder(server.MapPath(arrBaseFolder(3)))) <> 0 then
sBaseFolder_PhysicalPath = oFolder_base3.path 'folder terakhir tdk diikuti dgn / shg sFile_VirtualPath_UnderBaseFolder diawali dgn /
sBaseFolder = arrBaseFolder(3)
end if
end if
sFile_PhysicalPath = oFile.path
response.write "<!--Used for allocating problem:-->" & VbCrLf
response.write "<!--"&sFile_PhysicalPath&"-->" & VbCrLf
response.write "<!--"&sBaseFolder_PhysicalPath&"-->" & VbCrLf
sBaseFolder_PhysicalPath=LCase(sBaseFolder_PhysicalPath)'NEW 2.4
sFile_PhysicalPath=LCase(sFile_PhysicalPath)'NEW 2.4
sFile_VirtualPath_UnderBaseFolder = replace(replace(sFile_PhysicalPath,sBaseFolder_PhysicalPath,""),"\","/") 'physical to virtual, ex: "", "/gallery01", "/gallery02"
response.write "<!--"&sFile_VirtualPath_UnderBaseFolder&"-->" & VbCrLf
if mid(sFile_VirtualPath_UnderBaseFolder,1,1)="/" then
sFile_VirtualPath_UnderBaseFolder=mid(sFile_VirtualPath_UnderBaseFolder,2)
end if
response.write "<!--"&sFile_VirtualPath_UnderBaseFolder&"-->" & VbCrLf
sFile_VirtualPath = CStr(sBaseFolder & sFile_VirtualPath_UnderBaseFolder)
response.write "<!--"&sBaseFolder&"-->" & VbCrLf
response.write "<!--"&sFile_VirtualPath&"-->" & VbCrLf
if sColor = "#EFEFF5" then
sColor = ""
else
sColor = "#EFEFF5"
end if
'icons
sIcon="ico_unknown.gif"
If LCase(sExt)="asp" then sIcon="ico_asp.gif"
If LCase(sExt)="bmp" then sIcon="ico_bmp.gif"
If LCase(sExt)="css" then sIcon="ico_css.gif"
If LCase(sExt)="doc" then sIcon="ico_doc.gif"
If LCase(sExt)="exe" then sIcon="ico_exe.gif"
If LCase(sExt)="gif" then sIcon="ico_gif.gif"
If LCase(sExt)="htm" then sIcon="ico_htm.gif"
If LCase(sExt)="html" then sIcon="ico_htm.gif"
If LCase(sExt)="jpg" then sIcon="ico_jpg.gif"
If LCase(sExt)="js" then sIcon="ico_js.gif"
If LCase(sExt)="mdb" then sIcon="ico_mdb.gif"
If LCase(sExt)="mov" then sIcon="ico_mov.gif"
If LCase(sExt)="mp3" then sIcon="ico_mp3.gif"
If LCase(sExt)="pdf" then sIcon="ico_pdf.gif"
If LCase(sExt)="png" then sIcon="ico_png.gif"
If LCase(sExt)="ppt" then sIcon="ico_ppt.gif"
If LCase(sExt)="mid" then sIcon="ico_sound.gif"
If LCase(sExt)="wav" then sIcon="ico_sound.gif"
If LCase(sExt)="wma" then sIcon="ico_sound.gif"
If LCase(sExt)="swf" then sIcon="ico_swf.gif"
If LCase(sExt)="txt" then sIcon="ico_txt.gif"
If LCase(sExt)="vbs" then sIcon="ico_vbs.gif"
If LCase(sExt)="avi" then sIcon="ico_video.gif"
If LCase(sExt)="wmv" then sIcon="ico_video.gif"
If LCase(sExt)="mpeg" then sIcon="ico_video.gif"
If LCase(sExt)="mpg" then sIcon="ico_video.gif"
If LCase(sExt)="xls" then sIcon="ico_xls.gif"
If LCase(sExt)="zip" then sIcon="ico_zip.gif"
if(LCase(oFile.name)=LCase(sUploadedFile))then
sColorResult="yellow"
iSelected=nIndex
else
sColorResult=sColor
end if
Response.Write "<tr style='background:" & sColorResult & "'>" & VbCrLf & _
"<td><img src='images/"&sIcon&"'></td>" & VbCrLf & _
"<td valign=top width=100% ><u id=""idFile"&nIndex&""" style='cursor:pointer;' onclick=""selectFile(" & nIndex & ")"">" & oFile.name & "</u> <img style='cursor:pointer;' onclick=""downloadFile(" & nIndex & ")"" src='download.gif'></td>" & VbCrLf & _
"<input type=hidden name=inpFile" & nIndex & " id=inpFile" & nIndex & " value=""" & sFile_VirtualPath & """>" & VbCrLf & _
"<td valign=top align=right nowrap>" & FormatNumber(oFile.size/1000,1) & " kb </td>" & VbCrLf & _
"<td valign=top nowrap onclick=""deleteFile(" & nIndex & ")""><u style='font-size:10px;cursor:pointer;color:crimson' " & sFolderAdmin & ">" & VbCrLf
if not bWriteFolderAdmin then
Response.Write "<script>document.write(getTxt('del'))</script>" & VbCrLf
end if
Response.Write "</u></td></tr>" & VbCrLf
end if
next
if bFileFound=false then
Response.Write "<tr><td colspan=4 height=100% align=center><script>document.write(getTxt('Empty...'))</script></td></tr></table></div>"
else
Response.Write "<tr><td colspan=4 height=100% ></td></tr></table></div>"
end if
Response.Write "<input type=hidden name=inpUploadedFile id=inpUploadedFile value='" & iSelected & "'>"
Response.Write "<input type=hidden name=inpNumOfFiles id=inpNumOfFiles value='" & nIndex & "'>"
end function
assetmanager.txt
ASKER
I know how to get the SQL Statement I want and the specific images I want in a recordset.
I want to know how to adjust the code in the codebox above to display the images only fromt hat recordset.
Currently it displays all the contents of that folder. Can it be adjusted just to display the images from the recordset.
The 3rd Line:
set oFiles = oFolder.files
What is oFiles?
An array?
I want to know how to adjust the code in the codebox above to display the images only fromt hat recordset.
Currently it displays all the contents of that folder. Can it be adjusted just to display the images from the recordset.
The 3rd Line:
set oFiles = oFolder.files
What is oFiles?
An array?
hi harris9999,
What i suggest is, create seperate folder for each user... name it as per the user name or record id. then only it will be possible to show only the files assigned to each user.
What i suggest is, create seperate folder for each user... name it as per the user name or record id. then only it will be possible to show only the files assigned to each user.
You could also do an IF Statement.
<% if Request.QueryString("id")= ""&rs("userid")&"" then %>
Display images here
<% else %>
Do not display images
<% end if %>
Something like that.
This way it will look at the UsersID and compare it with the ID string.
And if they match then Show the information
If they do not match, then do not show the information
<% if Request.QueryString("id")=
Display images here
<% else %>
Do not display images
<% end if %>
Something like that.
This way it will look at the UsersID and compare it with the ID string.
And if they match then Show the information
If they do not match, then do not show the information
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
harris9999
I am sorry if my trying to help you has offended you in any way.
I am glad that you got it working, in what ever way that you was able to do it.
But
Just to add this.
I have site (Similur to MySpace) that I designed.
when I first designed it, it showed ALL Users images on the page.
I then went in and did the IF Statement to grab ahold of the logged in Users Cookie.
And that made it so that only the Logged in user could edit/update there images.
So, with that said, that is the reason why I suggested the IF statement to be used.
(I was not trying to make it look like you did not know what you was doing.
>>>>I know what an If Statement is and how it works.
)
Have a good one.
Close it out.
I am sorry if my trying to help you has offended you in any way.
I am glad that you got it working, in what ever way that you was able to do it.
But
Just to add this.
I have site (Similur to MySpace) that I designed.
when I first designed it, it showed ALL Users images on the page.
I then went in and did the IF Statement to grab ahold of the logged in Users Cookie.
And that made it so that only the Logged in user could edit/update there images.
So, with that said, that is the reason why I suggested the IF statement to be used.
(I was not trying to make it look like you did not know what you was doing.
>>>>I know what an If Statement is and how it works.
)
Have a good one.
Close it out.
ASKER
carrzkiss,
No problem. I probably wasn't clear enough in my question what I wanted.
I had that asset manager which was part of a wysiwyg editor I got. By default it pulls all the images from the folder by a method which I'm not too familiar with.
I was wondering if it could use the same functionality but just pull the appropriate records from the recordset.
I undertsand what you are saying
When I thought about it more clearly there was a more straight forward solution rather than my trying to use the function which I was not too familiar with.
Thanks anyway,
No problem. I probably wasn't clear enough in my question what I wanted.
I had that asset manager which was part of a wysiwyg editor I got. By default it pulls all the images from the folder by a method which I'm not too familiar with.
I was wondering if it could use the same functionality but just pull the appropriate records from the recordset.
I undertsand what you are saying
When I thought about it more clearly there was a more straight forward solution rather than my trying to use the function which I was not too familiar with.
Thanks anyway,
Say in your User Table you have
UserID
1
Your URL string will look like this: mysite.asp?uid=1
Now, in the page you can do this.
usid = Request.QueryString("uid)
strsql = "SELECT UserID FROM UsersTable WHERE UserID = "& usid &""
Now, when the page loads it will show all the records for that user only.
Let me know if you understand it?
have a good one.