Skulle inte kalla mig kunnig inom asp, men jag förstår lite hur det är uppbyggt (trodde jag) och pillar lite med färdiga script för att få det att fungera som jag vill.Antingen eller i webbshop-admin
Nu har jag fastnat på en grej som jag verkligen inte kan haja vad som är fel. Jag laddade hem scriptet "#580 - En klar Webshop" (http://www.pellesoft.se/communicate/userprogram/program.aspx?tid=580) härifrån pellesoft och det fungerde prima. Då jag vill kunna sortera kategorierna själv utan att behöva gå in via databasen la jag till en ändra-funktion i admin.asp som jag tog från "ändra produkt" och anpassade kopplingar och namn för att fungera för kategorier.
Efter lite pill så fungerar det att ändra informationen på en kategori. Då kommer problemet att under sidan "produkter" så visas ingenting. om jag ändrar så att produkter fungerar så fungerar inte "ändra"-länken under kategorier osv osv.
Jag har säkert glömt något skitlätt, men är som sagt ingen hejare på asp än så länge :p
Bifogar hela koden då jag inte vet vart problemet ligger
<%
'###################################################################
'# #
'# Denna applikation är skriven helt av Joakim på JoakimWeb.com. #
'# Applikationen får användas fritt, under förutsättning att copy- #
'# rightkoderna förblir intakta och att det inte sker i kommer- #
'# siella syften. #
'# www.joakimweb.com för mer scripter #
'# #
'###################################################################
%>
<!--#include file="installningar.asp"-->
<%
Set Connect = Server.CreateObject("ADODB.Connection")
'Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("webshop.mdb")
'Connect.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("webshop.mdb")
Connect.Open "DSN=db051_databas"
Session.Lcid = 1053
Function kollabild(text)
dim filesys, newfolder
set filer = CreateObject("Scripting.FileSystemObject")
mappen = Server.MapPath(mapp)
If Not filer.FolderExists(mappen) Then
filer.CreateFolder mappen
End If
filen = mapp & "/" & text & ".gif"
If Not filer.FileExists(Server.MapPath(filen)) Then
Response.Write " |<b> bild</b>"
Else
Response.Write " | bild"
End if
Set filer = Nothing
End Function
If len(Request("object")) <> 0 then
IF Request("object") = "login" then
IF Request("anvnamn") = admin_anvnamn And Request("losenord") = admin_losenord then
Session("webshoplogin") = "japp"
END IF
Response.Redirect "admin.asp"
ElseIF Request("object") = "category" then
IF Request("do") = "add" then
SQL = "INSERT INTO kategorier (namn,enamn,sort) VALUES('"& Request("namn") & "','"& Request("enamn") & "','"& Request("sort") & "')"
Connect.Execute(SQL)
ELSEIF Request("do") = "delete" then
SQL = "DELETE * FROM kategorier WHERE id=" & Request("id")
Connect.Execute(SQL)
SQL = "DELETE * FROM produkter WHERE kat=" & Request("id")
Connect.Execute(SQL)
ELSEIF Request("do") = "update" then
sort = Request("sort")
sort = Replace(sort,",",".")
SQL = "UPDATE kategorier SET namn='"&Request("namn")&"', enamn='"&Request("enamn")&"', sort="&Request("sort")&" WHERE id=" & Request("id")
Connect.Execute(SQL)
Response.Redirect "admin.asp?page=category"
END IF
Response.Redirect Request.ServerVariables("HTTP_REFERER")
ElseIF Request("object") = "product" then
IF Request("do") = "delete" then
SQL = "DELETE * FROM produkter WHERE id=" & Request("id")
Connect.Execute(SQL)
Response.Redirect "admin.asp?page=products"
ELSEIF Request("do") = "update" then
pris = Request("pris")
pris = Replace(pris,",",".")
SQL = "UPDATE produkter SET artnr='"&Request("artnr")&"' , namn='"&Request("namn")&"', beskrivning='"&Request("beskrivning")&"', pris='"&pris&"', kat="&Request("kat")&" WHERE id=" & Request("id")
Connect.Execute(SQL)
Response.Redirect "admin.asp?page=products"
ELSEIF Request("do") = "add" then
pris = Request("pris")
pris = Replace(pris,",",".")
SQL = "INSERT INTO produkter (artnr,namn,beskrivning,pris,kat) VALUES('"&Request("artnr")&"','"&Request("namn")&"','"&Request("beskrivning")&"',"&pris&","&Request("kat")&")"
Connect.Execute(SQL)
Response.Redirect "admin.asp?page=products"
END IF
END IF
Else
%><html>
<head>
<title>Webshop |Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#D2DCE6">
<div align="center">
<p><font size="5" face="Tahoma">Administration<br>
<strong><font size="1">Kategorier /
Produkter / Logga
ut</font></strong></font></p>
<%
IF Session("webshoplogin") = "japp" then
IF Request("page") = "category" then
IF Len(Request("cmore")) = 0 then%>
<table border="0">
<tr>
<td><div align="center"><font size="2" face="Tahoma"><strong>Produktkategorier</strong></font></div></td>
</tr>
<tr>
<td><div align="center"> <font face="Tahoma">
<%
SQL = "SELECT * FROM kategorier ORDER By sort"
Set RecSet = Connect.Execute(SQL)
IF RecSet.EOF then
Response.Write "inga kategorier"
ELSE
Do until RecSet.EOF
Response.Write "<b>" & RecSet("sort") & ". " & RecSet("namn") & "/" & RecSet("enamn") & "</b><br>Radera / Ändra<br><br>"
RecSet.MoveNext
Loop
END IF
RecSet.Close
Set RecSet = nothing
%>
</font></div></td>
</tr>
<tr>
<td><form name="form1" method="post" action="admin.asp?object=category&do=add">
<div align="center"> <font face="Tahoma"> Namn:<br>
<input name="namn" type="text" id="namn" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px"><br>Engelskt namn:<br>
<input name="enamn" type="text" id="enamn" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px"><br>Sortering:<br>
<input name="sort" type="text" id="sort" size="2" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px"><br>
<br>
<input type="submit" name="Submit" value="Lägg till" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></div>
</form></td>
</tr>
</table>
<%
ELSE IF Request("cmore") = "update" then%>
<%SQL = "SELECT * FROM kategorier WHERE id=" & Request("id")
Set RecSet = Connect.Execute(SQL)
%>
<form name="form5" method="post" action="admin.asp?object=category&do=update&id=<%=RecSet("id")%>">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2"><div align="center"><font size="2" face="Tahoma"><strong>Ändra
Kategori </strong></font></div></td>
</tr>
<tr>
<td><font face="Tahoma">Namn:</font></td>
<td><font face="Tahoma">
<input name="namn" type="text" id="namncu" value="<%=RecSet("namn")%>" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Engelska: </font></td>
<td><font face="Tahoma">
<input name="enamn" type="text" id="enamncu" value="<%=RecSet("enamn")%>" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Sortering: </font></td>
<td><font face="Tahoma">
<input name="sort" type="text" id="sortcu" value="<%=RecSet("sort")%>" size="2" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font face="Tahoma">
<input type="submit" name="Submit2222" value="Ändra" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></div></td>
</tr>
</table>
</form>
<%
RecSet.Close
Set RecSet = Nothing
ELSE IF Request("page") = "picture" then%>
<table border="0">
<form method="post" enctype="multipart/form-data" action="admin.asp?object=products&do=picture&id=<%=Request.Querystring("id")%>" name="frmUpload">
<tr>
<td><div align="center"><b><font size="2" face="Tahoma">Produktbild</font></b><br>
</div></td>
</tr>
<tr>
<td><div align="center"> <font face="Tahoma">Spara en bild i mappen<strong>
filer/</strong> med namnet <strong><%=Request("id")%>.gif</strong>
till produkten</font></div></td>
</tr>
<tr>
<td><div align="center"> <font face="Tahoma"><strong><<
Tillbaka</strong></font></div></td>
</tr>
</form>
</table>
<%
ELSEIF Request("page") ="products" then
IF Len(Request("more")) = 0 then%>
<table border="0">
<tr>
<td><div align="center"><font size="2" face="Tahoma"><strong>Produkter</strong></font></div></td>
</tr>
<tr>
<td><div align="center"> <font face="Tahoma">
<%
SQL = "SELECT * FROM produkter ORDER By namn"
Set RecSet = Connect.Execute(SQL)
IF RecSet.EOF then
Response.Write "inga produkter"
ELSE
Do until RecSet.EOF
Response.Write "<b>" & RecSet("namn") & "</b> | Radera / "
Response.Write "Ändra"
Response.Write " "& kollabild(RecSet("id"))&"<br>"
RecSet.MoveNext
Loop
END IF
RecSet.Close
Set RecSet = nothing
%>
</font></div></td>
</tr>
<tr>
<td><div align="center">Lägg
till produkt</div></td>
</tr>
</table>
<%
ELSE
IF Request("more") = "update" then
SQL = "SELECT * FROM produkter WHERE id=" & Request("id")
Set RecSet = Connect.Execute(SQL)
%>
<form name="form2" method="post" action="admin.asp?object=product&do=update&id=<%=RecSet("id")%>">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2"><div align="center"><font size="2" face="Tahoma"><strong>Ändra
produkt </strong></font></div></td>
</tr>
<tr>
<td><font face="Tahoma">Art.nr:</font></td>
<td><font face="Tahoma">
<input name="artnr" type="text" id="namn24" value="<%=RecSet("artnr")%>" size="5" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Namn:</font></td>
<td><font face="Tahoma">
<input name="namn" type="text" id="namn224" value="<%=RecSet("namn")%>" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Beskrivning: </font></td>
<td><font face="Tahoma">
<input name="beskrivning" type="text" id="namn2224" value="<%=RecSet("beskrivning")%>" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Pris:</font></td>
<td><font face="Tahoma">
<input name="pris" type="text" id="namn22222" value="<%=RecSet("pris")%>" size="10" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Kategori:</font></td>
<td><select name="kat" id="kat" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
<%
SQL = "SELECT * FROM kategorier ORDER BY namn"
Set RecSet2 = Connect.Execute(SQL)
Do until RecSet2.EOF
IF RecSet2("id") <> RecSet("kat") then
Response.Write "<option value='" & RecSet2("id") & "'>" & RecSet2("namn") & "</option>"
ELSE
Response.Write "<option value='" & RecSet2("id") & "' selected>" & RecSet2("namn") & "</option>"
END IF
RecSet2.MoveNext
Loop
RecSet2.Close
Set RecSet2 = nothing
%>
</select></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font face="Tahoma">
<input type="submit" name="Submit2" value="Ändra" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></div></td>
</tr>
</table>
</form>
<%
RecSet.Close
Set RecSet = Nothing
ELSEIF Request("more") = "add" then%>
<form name="form3" method="post" action="admin.asp?object=product&do=add">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2"><div align="center"><font size="2" face="Tahoma"><strong>Lägg
till produkt </strong></font></div></td>
</tr>
<tr>
<td><font face="Tahoma">Art.nr:</font></td>
<td><font face="Tahoma">
<input name="artnr" type="text" id="artnr" size="5" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Namn:</font></td>
<td><font face="Tahoma">
<input name="namn" type="text" id="namn25" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Beskrivning: </font></td>
<td><font face="Tahoma">
<input name="beskrivning" type="text" id="beskrivning" size="20" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Pris:</font></td>
<td><font face="Tahoma">
<input name="pris" type="text" id="pris" size="10" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></td>
</tr>
<tr>
<td><font face="Tahoma">Kategori:</font></td>
<td><select name="kat" id="select2" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
<%
SQL = "SELECT * FROM kategorier ORDER BY namn"
Set RecSet2 = Connect.Execute(SQL)
Do until RecSet2.EOF
Response.Write "<option value='" & RecSet2("id") & "'>" & RecSet2("namn") & "</option>"
RecSet2.MoveNext
Loop
RecSet2.Close
Set RecSet2 = nothing
%>
</select></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font face="Tahoma">
<input type="submit" name="Submit22" value="Spara" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></div></td>
</tr>
</table>
</form>
<%
END IF
END IF
ELSEIF Request("page") = "logout" then
Session.Contents.Remove("webshoplogin")
Response.Redirect "admin.asp"
ELSE%>
<font size="1" face="Tahoma">Klicka på länk ovan....</font>
<%END IF
END IF
END IF
END IF
ELSE%>
<form name="form4" method="post" action="admin.asp?object=login">
<table width="75" border="0">
<tr>
<td colspan="2"><div align="center"><font size="2" face="Tahoma"><strong>Logga
in</strong></font></div></td>
</tr>
<tr>
<td><div align="right"><font face="Tahoma">Anv.namn:</font></div></td>
<td><input name="anvnamn" type="text" id="beskrivning3" size="15" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px"></td>
</tr>
<tr>
<td><div align="right"><font face="Tahoma">Lösenord:</font></div></td>
<td><input name="losenord" type="password" id="anvnamn" size="15" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px"></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font face="Tahoma">
<input type="submit" name="Submit222" value="Logga in" style="background: #D2DCE6; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</font></div></td>
</tr>
</table>
</form>
<%END IF%>
</div>
</body>
</html>
<%END IF
Connect.Close
Set Connect = nothing %>