calliepeck
03-12-2006, 11:35 PM
ASP, in general, unfortunately. I'm still in the process of changing over from PHP and have been recommended to ASP as opposed to .NET. I'm skilled in neither. I'm trying to create a CMS with Access (will convert on the main server to sql server). It's doing all sorts of funky things like deleting after two clicks, sometimes writing to the database, sometimes not. I'm looking for a pattern in there, and I assume that it has to do with my conditional clauses, but I can't get those worked out. Anyone up for some code searching?
Cheers
<% 'If User Wants to Add:
if request.QueryString("add")=1 then
dim addnews
addnews=request.QueryString("add")
%>
<form name="hearing_update" class="update" action="update_hearings.asp" method="post">
<script language="JavaScript" type="text/javascript">
<!--
//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML)
initRTE("images/", "", "rte.css", true);
//-->
</script>
A bunch of form crap
<script language="javascript" type="text/javascript">
<!--
//Usage: write RichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('info','Enter the hearing information here. The formatting entered here will match the output formating.', 449, 250, true, false);
//-->
</script>
<input type="submit" name="Submit Query" value="Go"><input type="reset">
</form>
<% if request.Form("Submit Query")="Go" then
Dim h_headline, h_title, m, d, y, h_date, thetime, h_time, h_location, h_type, h_committee, h_committee2
h_title=request.Form("title")
h_headline=request.Form("head")
thetime=request.Form("time")
am_pm=request.Form("am_pm")
h_time=thetime&" "&am_pm
m=request.Form("mo")
d=request.Form("day")
y=request.Form("year")
h_date=m&"/"&d&"/"&y
h_location=request.Form("location")
h_type=request.Form("type")
h_committee=request.Form("committee")
h_committee2=request.Form("committee2")
sql="INSERT INTO hearings (h_title, h_headline, h_date, h_location, h_time, h_type, h_committee, h_committee2) VALUES ('"&h_title&"', '"&h_headline&"', '"&h_date&"', '"&h_location&"', '"&h_time&"', '"&h_type&"', '"&h_committee&"', '"&h_committee2&"')"
Set con = Server.CreateObject("ADODB.Connection")
con.Open MM_news_STRING
' Executing the sql insertion code
con.Execute sql
end if
%>
<% 'If User Wants to Delete:
else if request.QueryString("delete") then
id=request.QueryString("delete")
Dim sql
sql="DELETE FROM hearings WHERE id="&id&""
Set con = Server.CreateObject("ADODB.Connection")
con.Open MM_news_STRING
con.Execute sql
%>
<%else if not addnews then %>
<table width="500" cellpadding="2" cellspacing="2" bgcolor="#8B181B" class="admin">
<tr>
<td class="header">Date</td>
<td class="header">Title</td>
<td class="header"></td>
<td class="header"></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT display_news.EOF))
dim id
id=(display_news.Fields.Item("id").Value)
%>
<tr>
<td class="display"><%=(display_news.Fields.Item("h_date").Value)%></td>
<td class="display"><%=(display_news.Fields.Item("h_title").Value)%></td>
<td class="display"><a href="update_hearings.asp?delete=<% response.Write(id)%>">Delete</a></td>
<td class="display">Edit</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
display_news.MoveNext()
Wend
%>
</table>
<a href="update_hearings.asp?add=1">
<div style="border-style:solid;margin-top:12px;width:94px;background-color:#cccc99;text-align:center;padding:2px;border-width:2px;border-color:#000000;">
ADD A HEARING
</div>
</a>
<%
display_news.Close()
Set display_news = Nothing
end if
end if
end if
%>
Cheers
<% 'If User Wants to Add:
if request.QueryString("add")=1 then
dim addnews
addnews=request.QueryString("add")
%>
<form name="hearing_update" class="update" action="update_hearings.asp" method="post">
<script language="JavaScript" type="text/javascript">
<!--
//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML)
initRTE("images/", "", "rte.css", true);
//-->
</script>
A bunch of form crap
<script language="javascript" type="text/javascript">
<!--
//Usage: write RichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('info','Enter the hearing information here. The formatting entered here will match the output formating.', 449, 250, true, false);
//-->
</script>
<input type="submit" name="Submit Query" value="Go"><input type="reset">
</form>
<% if request.Form("Submit Query")="Go" then
Dim h_headline, h_title, m, d, y, h_date, thetime, h_time, h_location, h_type, h_committee, h_committee2
h_title=request.Form("title")
h_headline=request.Form("head")
thetime=request.Form("time")
am_pm=request.Form("am_pm")
h_time=thetime&" "&am_pm
m=request.Form("mo")
d=request.Form("day")
y=request.Form("year")
h_date=m&"/"&d&"/"&y
h_location=request.Form("location")
h_type=request.Form("type")
h_committee=request.Form("committee")
h_committee2=request.Form("committee2")
sql="INSERT INTO hearings (h_title, h_headline, h_date, h_location, h_time, h_type, h_committee, h_committee2) VALUES ('"&h_title&"', '"&h_headline&"', '"&h_date&"', '"&h_location&"', '"&h_time&"', '"&h_type&"', '"&h_committee&"', '"&h_committee2&"')"
Set con = Server.CreateObject("ADODB.Connection")
con.Open MM_news_STRING
' Executing the sql insertion code
con.Execute sql
end if
%>
<% 'If User Wants to Delete:
else if request.QueryString("delete") then
id=request.QueryString("delete")
Dim sql
sql="DELETE FROM hearings WHERE id="&id&""
Set con = Server.CreateObject("ADODB.Connection")
con.Open MM_news_STRING
con.Execute sql
%>
<%else if not addnews then %>
<table width="500" cellpadding="2" cellspacing="2" bgcolor="#8B181B" class="admin">
<tr>
<td class="header">Date</td>
<td class="header">Title</td>
<td class="header"></td>
<td class="header"></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT display_news.EOF))
dim id
id=(display_news.Fields.Item("id").Value)
%>
<tr>
<td class="display"><%=(display_news.Fields.Item("h_date").Value)%></td>
<td class="display"><%=(display_news.Fields.Item("h_title").Value)%></td>
<td class="display"><a href="update_hearings.asp?delete=<% response.Write(id)%>">Delete</a></td>
<td class="display">Edit</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
display_news.MoveNext()
Wend
%>
</table>
<a href="update_hearings.asp?add=1">
<div style="border-style:solid;margin-top:12px;width:94px;background-color:#cccc99;text-align:center;padding:2px;border-width:2px;border-color:#000000;">
ADD A HEARING
</div>
</a>
<%
display_news.Close()
Set display_news = Nothing
end if
end if
end if
%>