Jump to content

Deleting Rows In A Websites Content Managment System


danieleizik

Recommended Posts

hi.on my company's website, I have a "contact us" form which people send their details to us so we can call them.I'm updating the website through a content managment system (which I access on the web).The problem is that when I try to send some record (the form a man sent) from the "contact us" page in the content managment system (where I see all the forms people sent) to the recicle bin page, I can only send one record (form) at a time (I have to check the one's checkbox and press on the move to track bin button). If I try to check more then one checkbox and I press at the move to trash bin button, I get this error: mzmjign2zyrj.png (I added the file and line that the error shows) This is the page of all the forms people sent:4o4mezynmdyn.png This is the page code:

<!-- #include virtual="contentManagment/admin/includes/header.asp" --><!-- #INCLUDE File="func.asp" --><%whereCols = "where RECICLE = false"orderBy = "ORDER BY new desc"if action = "order" then  if Request.QueryString("DESC") = "1" then   orderBy = "ORDER BY " & Request.QueryString("ORDER_BY") & " desc"  else   orderBy = "ORDER BY " & Request.QueryString("ORDER_BY")  end ifend if if action = "filter" then  if Request.Form("FILTER_USER") = 0 then   whereCols = "where RECICLE = false"  else   whereCols = "where article_category = " & Request.Form("FILTER_USER") & " and RECICLE = false "  end if		end if%><!-- #include virtual="contentManagment/admin/includes/menuLinks.asp" --><form method=post id=myForm name=myForm action=contactIndex.asp?action=updateOrder><tr>  <td colspan=4 class=menubackgr>	 <div align="center">	  <table width="100%"  border="0" cellspacing="0" cellpadding="0">	   <tr>		<!-- #include virtual="contentManagment/admin/includes/navigatorBar.asp" -->		<!-- #INCLUDE File="toolBar.asp" -->	   </tr>	  </table>	 </div>  </td></tr></table><table width=100%> <!-- #include virtual="contentManagment/admin/includes/pageMessage.asp" --><tr>  <td colspan=2>   <div>	<script language=JavaScript type=text/javascript>  	 function doDelete()	 {		   document.myForm.action = "<%=pageName%>?action=delete";	   document.myForm.submit();	 }	 function doEdit()	 {	  document.myForm.action = "contactEdit.asp";	  document.myForm.submit();	 }  	 function doFilter()	 {	  document.myForm.action = "<%=pageName%>?action=filter";	  document.myForm.submit();	 }	 function doEmpty()	 {	  if(confirm('<%=alert_delete_user_and_permitions%>'))	  {		   document.myForm.action = "<%=pageName%>?action=deleteall";	   document.myForm.submit();	  }	 }			</SCRIPT>	<table class=adminlist>	 <TBODY>	  <tr>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=ID&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_id%></A></th>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=ID&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_id%></A></th>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=date_sent&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_contact_date_sent%></A></th>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=sender_title&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_contact_sender_title%></A></th>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=sender_name&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_contact_sender_name%></A></th>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=sender_mail&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_contact_sender_mail%></A></th>	   <th><A style="color: #ffffff" HREF="<%=pageName%>?action=order&ORDER_BY=sender_phone&DESC=<%if Request.QueryString("DESC") = "0" or Request.QueryString("DESC") = "" then%>1<%else%>0<%end if%>"><%=lang_contact_phone%></A></th>	   <th>#</th>	  </tr>			 <%	  mySQL = "select * from contact_table " & whereCols & " " & orderBy & ";"	  'Response.Write mySQL	  Set RS = Server.CreateObject( "ADODB.Recordset" )	  RS.Open mySQL, Con, adOpenStatic, adLockOptimistic	  theclass = "row0"		  if not RS.EOF then	   while not RS.EOF	  	 %>			  	  <tr class="<%=theclass%>">		<td align=middle><%=getAnvelopeStatus(RS("new"))%></td>		<td align=middle><%=RS("ID")%></td>		<td align=middle><%=RS("date_sent")%></td>		<td align=middle><%=RS("sender_title")%></td>		<td align=middle><%=RS("sender_name")%></td>		<td align=middle><A HREF="mailto:<%=RS("sender_mail")%>"><%=RS("sender_mail")%></A></td>		<td align=middle><%=RS("sender_phone")%></td>		<td align=middle><INPUT type="checkbox" id=selectedRow name=selectedRow value="<%=RS("ID")%>"></td>	  </tr>	 </tbody>	<%		if theclass = "row1" then	  		 theclass = "row0"	  		else		 theclass = "row1"		end if			RS.MoveNext	   wend	   RS.Close	   Set RS = Nothing	  else	   RS.Close	   Set RS = Nothing	  end if	%>			</table>   </div>  </td></tr></table></form><!-- #include virtual="contentManagment/admin/includes/footer.asp" -->

and This is the code of the func.asp page code:

<%dim actionaction	= Request.QueryString("action")if action = "delete" then  if Request.Form("selectedRow") <> "" then     tableName	= "contact_table"   record_id	= Request.Form("selectedRow")   record_name = "<STRONG>"&lang_del_from&"</STRONG> " & getRecordName("contact_table",Request.Form("selectedRow"),"sender_name") & " ," &_		"<STRONG>"&lang_del_titel&"</STRONG> " & getRecordName("contact_table",Request.Form("selectedRow"),"sender_title")	     if not deleteRowFromTable2(tableName,record_id,record_name) then	errorMsg = errMsg_noRowSelected & "<br>"   else	sucssesMsg = sucssesMsg & sucssesMsg_deleteUserSuc & "<br>"   end if    else   errorMsg = errMsg_noRowSelected & "<br>"  end if  end if %>

I managed to add the deleteall action and a erase all button to the page's code but I just dont know what to do with it. please help.I have over 1000 forms in there so i cant delete them all manually.after I can transfer them to the recicle bin, it is easy to erase all of them. there is a button for that in there. thanks and sorry for my bad English, Daniel.

Link to comment
Share on other sites

The error message is saying that the SQL failed because there is a comma-separated list of IDs instead of a single ID. You need to change the code to check for commas in the ID, which would indicate a list of IDs instead of a single one, and if it is a list then you need to break up the list of IDs into the individual IDs, and loop through them to run the SQL for each ID.

Link to comment
Share on other sites

Use the split function to break up the list of IDs: http://www.w3schools.com/vbscript/func_split.asp Split up the ID variable on a comma, and you'll get an array of items that were separated with commas. There's an example that shows using a comma as the delimiter. Once you have the array of IDs, you can use a For..Each loop to loop through each ID: http://www.w3schools.com/vbscript/vbscript_looping.asp For each ID that is in the array, use the code you have to send the delete query to the database with the ID from the array.

Link to comment
Share on other sites

thanks but where should I place the split function? and how should I use it?So, in this code:<script type="text/vbscript"> a=Split("T",",")for each x in a document.write(x & "<br />")next </script> what should I write instead of T?and where should I write this code?thanks again

Link to comment
Share on other sites

The first parameter to the split function is the string you want to split, so it is the list of IDs that was submitted with the form. You need to split up the list of IDs so that you can loop through them and run your existing delete code for each ID in the list. So the existing delete code needs to go inside a loop, and the ID to delete should be coming from the list of IDs that you split.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...