<html>
<head>
<title>Custom Home Builder, Perth Western Australia</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="style.css">
</head>
<body>
<div style="background:#FFFFFF; width:100%; height:100%"><table width="400" bgcolor="#FFFFFF" align="center" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td width="400" height="20"></td>
	</tr>
<%
On Error Resume Next
Response.Expires = 0
Dim objConn, objRS, strQuery, PobjRS, PstrQuery
Dim strConnection
Dim tPID
Dim count

if Session("Admin") = "" then
  Response.Write "<tr><td width=""400"" height=""150"" align=""center"" class=""h2"">You have been logout.</td></tr>"
else

Set objConn = Server.CreateObject("ADODB.Connection")
strConnection = "DSN=PHBlog;Database=BlogDB.MDB;"

objConn.Open strConnection

tPID = Request.QueryString("pid")

PstrQuery = "SELECT * FROM Product WHERE ID = " & tPID
Set PobjRS = objConn.Execute(PstrQuery)

strQuery = "SELECT * FROM Category ORDER BY Rank"
Set objRS = objConn.Execute(strQuery)

if objRS.EOF then
%>							
	<tr>
		<td width="400" height="50"></td>
	</tr>
	<tr>
		<td width="400" align="center" class="p">Currently there are no categories available.</td>
	</tr>
<%
else
%>								
	<tr>
		<td align="center" class="h1"><%= PobjRS("Title") %></td>
	</tr>
	<tr>
		<td height="20"></td>
	</tr>
	<form name="fmEditProduct" method="post" action="productCategoryUpdate.asp">
	<tr>
		<td align="center"><table border="0" cellpadding="0" cellspacing="0">
        	<input type="hidden" name="ID" value="<%= PobjRS("ID") %>">
<%
	count = 1
	
	Do While not objRS.EOF
	
		PCstrQuery = "SELECT * FROM ProductCategory WHERE ProductID = " & tPID & " AND CategoryID = " & objRS("ID")
		Set PCobjRS = objConn.Execute(PCstrQuery)

		Response.Write "<tr>"
		if PCobjRS.EOF then
			Response.Write "<td><input name=""category" & count & """ type=""checkbox"" value=""" & objRS("ID") & """></td>"
		else
			Response.Write "<td><input name=""category" & count & """ type=""checkbox"" value=""" & objRS("ID") & """ checked></td>"
		end if
		Response.Write "<td width=""10""></td>"
		Response.Write "<td class=""p"">" & objRS("Name") & "</td>"
		Response.Write "</tr>"

		count = count + 1
		objRS.MoveNext
	Loop

    Session("TNumber") = count - 1
%>                                    
		</table></td>
	</tr>			
	<tr>
		<td height="10"></td>
	</tr>			
	<tr>
		<td height="25" align="center"><input name="submit" type="submit" value="Submit" class="submit"></td>
	</tr>
	</form>
<%
end if

PobjRS.close
objConn.close
Set PobjRS = Nothing
Set objConn = Nothing

end if
%>
	<tr>
		<td width="400" height="20"></td>
	</tr>
</table></div>
</body>
</html>