Hjælp til ASP kode ???
Hej Alle ASP nørderEr der nogen som kan hjælpe mig med lidt kode ?
Jeg har følgende 2 ASP script filer, som jeg gerne vil have til at vise de nyeste poster først og de ældste sidst, lige nu gør den det modsat ældste først og nyeste sidst.
Derudover vil jeg gerne have tilknyttet muligheden for, at kunne skrive både et emne og en beskrivelse til billederne og ikke kun beskrivelse som nu.
Kan man også lave en funktion så jeg kan rette eller slette en post der ikke skal være der mere ?
På forhånd tak for hjælpen.
Her er det upload.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Response.buffer = true%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Billedgalleri</title>
<style type="text/css">
<!--
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FF0000;
}
a:hover {
text-decoration: underline;
color: #CC0000;
}
a:active {
text-decoration: none;
color: #cC000C;
}
body,td,th {
color: #000000;
}
body {
background-color: #336699;
}
-->
</style></head>
<body>
<%
strmode = request.QueryString("mode")
UploadPics = 10
if strmode="flere" or strmode="" or strmode="done" then
if strmode="done" then
response.write "File(n/rne) blev uploaded"
end if
iAntal = Cint(request.form("antal"))
if iAntal < 1 or iAntal = "" then
iAntal = 1
end if
response.write "<center><a href='visbilleder.asp'>Se billederne</a></center>"
response.write "<form action='?mode=upload' method='post' enctype='multipart/form-data'>"
for ie = 1 to iAntal
response.write "<input type='file' name='billede" & ie & "'>"
response.write " Beskrivelse: <input type='text' name='description" & ie & "'><br>"
next
response.write "<input type='submit' value='Upload!'>"
response.write "</form><br>"
response.write "upload flere filer på en gang:<br>"
response.write "<form action='?' method='post'>"
response.write "<select name='antal'>"
for ie = 1 to UploadPics
response.write "<option value='" & ie & "'>" & ie & "</option>"
Next
response.write "</select><input type='submit' value='Opdater'></form>"
elseif strmode="upload" then
dim oUpload
set oUpload = server.CreateObject("aspSmartUpload.SmartUpload")
oUpload.MaxFileSize = 5000001 '5000kb
oUpload.AllowedFilesList = "jpg,JPG,gif,GIF,bmp,BMP,jpeg,JPEG"
on Error resume next
dim strUploadPath
dim strFile
dim strExt
dim i
i = 1
strUploadPath = "foto1/foto1"
oUpload.upload
for each File in oUpload.files
strFile = File.FileName
if strFile = "" then
response.write "Du skal vælge en fil!"
else
set conn = server.CreateObject("adodb.connection")
set rs = server.CreateObject("adodb.recordset")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("billeder.mdb")
sql="select * from billeder where name='" & strFile & "'"
set rs = conn.execute(sql)
if rs.eof then
File.SaveAs(server.MapPath(Lcase(strUploadpath & strFile)))
if Err then
response.write "Der skete en fejl: " & err.description
else
sql ="insert into billeder(name, description, path, uploaded) VALUES('" & strFile & "', '" & oUpload.form.item("description" & i) & "', '" & strUploadpath & strFile & "', #" & now() & "#)"
conn.execute(sql)
end if
else
response.write "En fil med dette navn findes allerede, omdøb filen og prøv igen"
end if
end if
i = i+1
next
if not err then
response.redirect "upload.asp?mode=done"
end if
On Error goto 0
rs.close
conn.close
set rs = nothing
set conn = nothing
set oUpload = nothing
end if
%>
</body>
</html>
og her er det visbilleder.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Vis billeder</title>
<style type="text/css">
<!--
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FF0000;
}
a:hover {
text-decoration: underline;
color: #cc000c;
}
a:active {
text-decoration: none;
color: #cc000c;
}
body,td,th {
color: #000000;
}
body {
background-color: #FFFFFF;
}
-->
</style></head>
<body>
<%
set conn = server.CreateObject("adodb.connection")
set rs = server.CreateObject("adodb.recordset")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("billeder.mdb")
strPageSize = 1 'antal billeder på hver linie
sql="select * from billeder"
set rs = conn.execute(sql)
response.write "<a href='upload.asp'>Upload nyt billede</a><br>"
if rs.eof then
response.write "Der er ingen billeder gemt i databasen!"
else
ArrBeskrivelse = ""
ArrUploaded = ""
rs.movefirst
do while not rs.eof
beskrivelse = beskrivelse & rs("description") & ","
uploaded = uploaded & rs("uploaded") & ","
rs.movenext
loop
ArrBeskrivelse = Split(beskrivelse, ",")
ArrUploaded = Split(uploaded, ",")
rs.movefirst
i = 0
total = 0
response.write "<table><tr>"
do while not rs.eof
i = i + 1
total = total + 1
response.write "<td width='125' height='150'><img width='125' height='150' src='" & rs("path") & "'"
response.write " alt='" & rs("description") & "'></td>"
if i = strPageSize then
response.write "</tr><tr>"
iNummer = Cint(total)-Cint(strPageSize)
for ie = 1 to strPageSize
response.write "<td width='125' height='150'>"
if ArrBeskrivelse(iNummer) = "" then
response.write "Ingen beskrivelse"
else
response.write ArrBeskrivelse(iNummer)
end if
response.write "<br>Uploaded: " & ArrUploaded(iNummer) & "</td>"
iNummer = iNummer + 1
next
response.write"</tr><tr>"
i = 0
end if
rs.movenext
loop
if i < strPageSize then
iNummer = Cint(total-i)
response.write "</tr><tr>"
for ie = 1 to i
response.write "<td width='125' height='150'>"
if ArrBeskrivelse(iNummer) = "" then
response.write "Ingen beskrivelse"
else
response.write ArrBeskrivelse(iNummer)
end if
response.write "<br>Uploaded: " & ArrUploaded(iNummer) & "</td>"
iNummer = iNummer + 1
next
response.write "</tr>"
end if
response.write "</table>"
end if
%>
</body>
</html>