Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Shopping Cart

Status
Not open for further replies.

shawntbanks

Programmer
Oct 29, 2003
48
CA
I am trying to develop a shopping cart for a classified ad site, I know now that it is going to be different than a regular retail site, because I am selling I full description and not just a item. I want to be able to have a person enter all the information about a product including 4 pictures. then I want the customer to be able to view the ad and add more if they want to before they check out. Any help would be appricated
 
As for the old images still existing on your server... yes, this is to be expected (since you're using the MAKEUNIQUE attribute of your CFFILE tag... none of the old files are going to be overwritten).

You'd need to create a process manually that scans your database table and creates a list of all the images that are currently being used, then scans the images directory and deletes any files that aren't in that "used" list.

Something like:
Code:
<CFQUERY name=&quot;getImages&quot; ...>
   SELECT picture1, picture2, picture3, picture4
     FROM ...
</CFQUERY>

<CFSET lstUsedPictures = ValueList(getImages.picture1)>
<CFSET lstUsedPictures = ListAppend(&quot;#lstUsedPictures#&quot;,ValueList(getImages.picture2)>
<CFSET lstUsedPictures = ListAppend(&quot;#lstUsedPictures#&quot;,ValueList(getImages.picture3)>
<CFSET lstUsedPictures = ListAppend(&quot;#lstUsedPictures#&quot;,ValueList(getImages.picture4)>

<CFDIRECTORY action=&quot;list&quot; name=&quot;directoryFiles&quot; directory=&quot;/whateverdirectory/&quot; ...>

<CFLOOP query=&quot;directoryFiles&quot;>
   <CFIF ListFind(&quot;#lstUsedPictures#&quot;,directoryFiles.name) LTE 0>
      <CFFILE action=&quot;delete&quot; file=&quot;/whateverdirectory/#directoryFiles.name#&quot; ...>
   </CFIF>
</CFLOOP>

and then you can set up your CF scheduler to fire the process every hour or whatever and it'll clean out the directory.


-Carl
 
Thanks for the reply, I have been a little tied up with some other things. I looked over the code that you have given me, and tried to make sence of it and I think that I definetly understand it a little more, still a little hairy in some places, but not bad. I incorporated my code into it and made a few adjustments, and it seems to be going good, I can't thank you enough for the help that you are giving me. when it comes to deleting and modifying an item I am starting to tackle. I put the links in to do so, but not sure on the approach to take. Here are the 3 new pages.

--------------------------------------------------------------------------------------------------

Page1.cfm
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>

<cfset today = #now()# + 1>
<cfset Todays_Date = #dateformat(today, &quot;mm/dd/yyyy&quot;)#>

<cfquery name=&quot;get_Communities&quot; datasource=&quot;Market&quot;>
SELECT *
FROM Communities
order by location
</cfquery>

<cfquery name=&quot;get_SubCategories&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
</cfquery>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder_Subcat_Select.cfm&quot;>
<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>

<cfform action=&quot;Page2.cfm&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>
<cfoutput><input type=&quot;hidden&quot; name=&quot;submitID&quot; value=&quot;#createUUID()#&quot;></cfoutput>
<input type=&quot;hidden&quot; value=&quot;#form.select_Ad_Subcategory#&quot; name=&quot;subcategoryid&quot;>
<input type=&quot;hidden&quot; value=&quot;#categoryids&quot; name=&quot;CategoryID&quot;>
<table align=&quot;center&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;5&quot; class=&quot;FormHeaders&quot;><div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><!--- <cfoutput>#categories.Category#</cfoutput> --->
Details</font></div></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Category:</font></td>
<td valign=&quot;top&quot; colspan=&quot;4&quot;>
<select name=&quot;select_Ad_Subcategory&quot; onchange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<option>- Select Category-</option>
<!--- again, use the group attribute to group output by category --->
<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<option value=&quot;#Categoryid#&quot;>#Category#</option>
</cfoutput>
</select></td></tr>
<tr><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Subcategory:</font></td>
<td colspan=&quot;4&quot;> <select name=&quot;selectLocal&quot; onChange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<option>- Select SubCategory -</option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>

<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Community:</font></td>
<td colspan=&quot;4&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>
<select name=&quot;Community_List&quot;>

<option></option>
<cfoutput query=&quot;Get_Communities&quot;>
<option value=&quot;#location#&quot;>#location#</option>
</cfoutput>
</select>
</font></td>
</tr>
<tr>
<td width=&quot;109&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name:</font></td>
<td colspan=&quot;4&quot;> <font face=&quot;Georgia, Times New Roman, Times, serif&quot;>

<CFinput name=&quot;Itemname&quot; type=&quot;text&quot; required=&quot;no&quot; message=&quot;Item Name Required&quot;>
</font></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Short
Description:</font></td>
<td colspan=&quot;4&quot;>
<textarea name=&quot;Short_description&quot; cols=&quot;30&quot; rows=&quot;5&quot; wrap=&quot;hard&quot; onChange=&quot;if (this.value.length > 100) {alert('The Short Description Cannot Be Greater Than 100 Chars.')};&quot;>Text entered here will be entered in the listings page</textarea>

</td>
</tr>
<tr>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Long
Description:</font></td>
<td colspan=&quot;4&quot;><textarea name=&quot;Long_description&quot; cols=&quot;30&quot; rows=&quot;5&quot;>Text entered here will show up on your details page</textarea>

</td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Asking
Price:</font></td>
<td colspan=&quot;4&quot;><CFinput name=&quot;itemprice&quot; value=&quot;&quot; type=&quot;text&quot; id=&quot;itemprice&quot; required=&quot;no&quot; message=&quot;Asking Price Required&quot; size=&quot;20&quot; maxlength=&quot;9&quot;>

</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><span >Featured
Item</span><font color=&quot;#FF0000&quot;>*</font></font></td>
<td colspan=&quot;4&quot;> <CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot; checked=&quot;yes&quot;>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Yes</font> </td>
<tr><td> </td><td colspan=&quot;4&quot;><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot;>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>No</font> </td></tr>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Start
Date Of Ad:</font></td>
<td colspan=&quot;4&quot;><cfinput name=&quot;begindate&quot; type=&quot;text&quot; validate=&quot;date&quot; value=&quot;#Todays_Date#&quot;>
</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Length
Of Ad:</font></td>
<td><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot; checked=&quot;yes&quot;></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>7
Days</font></td>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;> </font></td>
<td><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot;></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>30 Days
</font></td>
</tr></table>

<table align=&quot;center&quot;>
<tr><td colspan=&quot;5&quot;><BR><BR><div align=&quot;center&quot;><strong>Up to 4 pictures
can be submited with your ad</strong></div></td>
</tr>
<tr>
<td><strong>1:</strong></td>

<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;picture1&quot; accept=&quot;image/gif,image/jpeg&quot;></td>

</tr>
<tr>
<td><strong>2:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;picture2&quot; accept=&quot;image/gif,image/jpeg&quot;></td>
</tr>
<tr>
<td><strong>3:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;picture3&quot; accept=&quot;image/gif,image/jpeg&quot;></td>
</tr>
<tr>
<td><strong>4:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;picture4&quot; accept=&quot;image/gif,image/jpeg&quot;></td>
</tr></tr>
<tr bgcolor=&quot;#FFFFFF&quot;>
<td colspan=&quot;5&quot;><div align=&quot;center&quot;>
<input type=&quot;submit&quot; value=&quot;Continue >>&quot;>
</div></td>
</tr>
</table>


</cfform>



<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>


page2.cfm


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>Confirm Ad</title>
<!--- <CFQUERY NAME=&quot;vendorInfo&quot; DATASOURCE=&quot;market&quot;>
select *
from vendors
where vendorid = #SESSION.Auth.vendorID#
</cfquery> --->
<cfquery name=&quot;Sort_categories&quot; datasource=&quot;market&quot;>
select *
from subandcat
Where subcategoryid = #form.selectLocal#
</cfquery>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder.cfm&quot;>


<td width=&quot;605&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>
<!--- did the user get here from the ad submission page? --->
<CFIF IsDefined(&quot;FORM&quot;) AND IsStruct(FORM) AND NOT StructIsEmpty(FORM) AND IsDefined(&quot;FORM.submitid&quot;)>
<!--- yes, the user got here from the form --->

<CFSET bValidSubmit = true>
<!--- lock the session scope and check the list of previously submitted submitIDs... if there's a match, the submission is not valid --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
<CFIF IsDefined(&quot;session.submittedIDs&quot;) AND ListFind(&quot;#session.submittedIDs#&quot;,FORM.submitID) GT 0>
<CFSET bValidSubmit = false>
</CFIF>
</CFLOCK>

<!--- only proceed if an ad with this submitID hasn't already been submitted --->
<CFIF bValidSubmit>
<!--- set up some directory variables --->
<CFSET webRootDirectory = &quot;C:\Inetpub\ <CFSET pictureDirectory = &quot;\marketingedgeinc\sale_item_Images\&quot;>
<CFSET picture1filename = &quot;&quot;>
<CFSET picture2filename = &quot;&quot;>
<CFSET picture3filename = &quot;&quot;>
<CFSET picture4filename = &quot;&quot;>

<!--- upload the pictures as appropriate --->
<CFIF Len(Trim(FORM.picture1)) GT 0>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;picture1&quot; accept=&quot;image/*&quot; destination=&quot;#webRootDirectory##pictureDirectory#&quot;>
<CFSET picture1filename = GetFileFromPath(CFFILE.serverfile)>
</CFIF>
<CFIF Len(Trim(FORM.picture2)) GT 0>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;picture2&quot; accept=&quot;image/*&quot; destination=&quot;#webRootDirectory##pictureDirectory#&quot;>
<CFSET picture2filename = GetFileFromPath(CFFILE.serverfile)>
</CFIF>
<CFIF Len(Trim(FORM.picture3)) GT 0>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;picture2&quot; accept=&quot;image/*&quot; destination=&quot;#webRootDirectory##pictureDirectory#&quot;>
<CFSET picture3filename = GetFileFromPath(CFFILE.serverfile)>
</CFIF>
<CFIF Len(Trim(FORM.picture4)) GT 0>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;picture2&quot; accept=&quot;image/*&quot; destination=&quot;#webRootDirectory##pictureDirectory#&quot;>
<CFSET picture4filename = GetFileFromPath(CFFILE.serverfile)>
</CFIF>


<form action=&quot;page3.cfm&quot; method=&quot;post&quot;>


<table border=&quot;0&quot;>
<tr>
<td colspan=&quot;2&quot;><div align=&quot;center&quot;> <div align=&quot;center&quot;> Here's
the ad you've submitted: </div></td>
</tr>
<tr>
<td colspan=&quot;2&quot;><HR>
<BR>
<BR></td>
</tr>
<tr>
<td valign=&quot;bottom&quot;><cfoutput> <input type=&quot;hidden&quot; name=&quot;Short_Description&quot; value=&quot;#form.Short_Description#&quot;>
<div align=&quot;left&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Information
On </font><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#FORM.Itemname#</font></div>
<input type=&quot;hidden&quot; name=&quot;itemname&quot; value=&quot;#FORM.itemname#&quot;>

</cfoutput></td>
</tr>
<tr>
<td>
<tr>
<td><table border=&quot;0&quot;>
<tr>
<CFIF Len(Trim(picture1filename)) GT 0>
<td width=&quot;106&quot;>
<CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/#picture1filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;picture1filename&quot; value=&quot;#picture1filename#&quot;>
</CFOUTPUT> </td>
</cfif>
<CFIF Len(Trim(picture2filename)) GT 0>
<td width=&quot;106&quot;>
<CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/#picture2filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;picture2filename&quot; value=&quot;#picture2filename#&quot;>
</CFOUTPUT> </td>
</cfif>
<CFIF Len(Trim(picture3filename)) GT 0>
<td width=&quot;106&quot;>
<CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/#picture3filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;picture3filename&quot; value=&quot;#picture3filename#&quot;>
</CFOUTPUT> </td>
</cfif>
<CFIF Len(Trim(picture4filename)) GT 0>
<td width=&quot;106&quot;>
<CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/#picture4filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;picture4filename&quot; value=&quot;#picture4filename#&quot;>
</CFOUTPUT> </td>
</cfif>
</tr>
</table></td>
</tr>
<tr>
<td > <table>
<tr>
<td width=&quot;269&quot; bgcolor=&quot;#339900&quot;><strong><font size=&quot;3&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Price</font></strong></td>
<td width=&quot;310&quot; bgcolor=&quot;#339900&quot; colspan=&quot;4&quot;><div align=&quot;center&quot;><font size=&quot;3&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><strong>Location</strong></font></div></td>
</tr>
<cfoutput>
<tr>
<td class=&quot;FormText&quot;><strong>#Dollarformat(form.itemPrice)#</strong></td>
<input type=&quot;hidden&quot; name=&quot;itemprice&quot; value=&quot;#FORM.itemprice#&quot;>
<td colspan=&quot;4&quot;> <div align=&quot;center&quot;>#form.Community_List#</div></td>
<input type=&quot;hidden&quot; name=&quot;location&quot; value=&quot;#FORM.Community_List#&quot;>
</tr>
</cfoutput></table></td>
</tr>
<tr>
<td><table>
<tr><cfoutput>
<td width=&quot;361&quot; bgcolor=&quot;EDECE0&quot; class=&quot;LongDesc&quot;>#form.Long_description#</td>
<input type=&quot;hidden&quot; name=&quot;long_description&quot; value=&quot;#FORM.Long_description#&quot;>
</cfoutput>
<!--- <cfoutput query=&quot;vendorInfo&quot;> --->
<td width=&quot;212&quot;><div align=&quot;center&quot;>
<p class=&quot;LongDesc&quot;>For more information, contact:<br>
<strong>
<!--- <a href=&quot;mailto:#email#&quot;>#email#</a> --->
</strong></p>
</div></td>
<!--- </cfoutput> --->
</tr>
</table></td>
</tr>
<tr>
<TD><hr></TD>
<td></td>
</tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Your
ad will run from   <cfoutput><strong><u>#dateformat(form.begindate, &quot;mm/dd/yyyy&quot;)#</u>   </strong> to   <strong><u>#dateformat(form.begindate + form.Enddate, &quot;mm/dd/yyyy&quot;)#</u></strong></font> <input type=&quot;hidden&quot; name=&quot;begindate&quot; value=&quot;#form.begindate#&quot;>
<input type=&quot;hidden&quot; name=&quot;enddate&quot; value=&quot;#form.enddate#&quot;></cfoutput>
</td>
</tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>and
be placed in subcategory <strong>(#Sort_categories.Subcategory#)</strong> within category <strong>(#Sort_categories.category#)</strong>
<input type=&quot;hidden&quot; name=&quot;select_Ad_Subcategory&quot; value=&quot;#FORM.select_Ad_Subcategory#&quot;>
<input type=&quot;hidden&quot; name=&quot;selectLocal&quot; value=&quot;#FORM.selectLocal#&quot;>
<input type=&quot;hidden&quot; name=&quot;SUB&quot; value=&quot;#Sort_categories.Subcategory#&quot;>
</cfoutput></font></td></tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Featured?  
<cfif form.featured EQ 1>
<strong>Yes</strong>
<cfelse>
<strong>No </strong>
</cfif>
</font></td>
</tr>
<tr> <cfoutput>
<input type=&quot;hidden&quot; name=&quot;featured&quot; value=&quot;#form.featured#&quot;>
</cfoutput>
<td colspan=&quot;2&quot;><BR>
<BR>
<HR></td>
</tr>
<CFOUTPUT>
<input type=&quot;hidden&quot; name=&quot;submitid&quot; value=&quot;#FORM.submitid#&quot;>
</CFOUTPUT>
<tr>
<td colspan=&quot;2&quot; class=&quot;LongDesc&quot;><div align=&quot;center&quot;>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Add to cart&quot;>
</div></td>
<CFELSE>
<!--- the submitID was found in the list of previously submitted ads... so this submission is not valid --->
<table><tr><td>You've already submitted this ad. <a href=&quot;page3.cfm&quot;>Click
here</a> to view your cart.</td></tr></table> </CFIF> <CFELSE>
<!--- no... the user must've gotten here by mistake (no form was submitted), so take them back to page 1 --->
<CFLOCATION url=&quot;page1.cfm&quot;> </CFIF>
</tr>
</table>


</form>


</tr>
<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>


<!---
<!--- display the ad and ask for confirmation that the user wants to actually add it to their cart... behind the scenes, construct a form with hidden fields to pass all the relevent data to the next page --->
Here's the ad you've submitted:

<form action=&quot;page3.cfm&quot; method=&quot;post&quot;>

<p>Item Name: <CFOUTPUT>#FORM.itemname#<input type=&quot;hidden&quot; name=&quot;itemname&quot; value=&quot;#FORM.itemname#&quot;></CFOUTPUT></p>

<p>Category: <CFOUTPUT>#FORM.category#<input type=&quot;hidden&quot; name=&quot;category&quot; value=&quot;#FORM.category#&quot;></CFOUTPUT></p>

<p>Images:<br />
<CFIF Len(Trim(picture1filename)) GT 0>
<CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/#picture1filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;><input type=&quot;hidden&quot; name=&quot;picture1filename&quot; value=&quot;#picture1filename#&quot;></CFOUTPUT><br />
</CFIF>
<CFIF Len(Trim(picture2filename)) GT 0>
<CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/#picture2filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;><input type=&quot;hidden&quot; name=&quot;picture2filename&quot; value=&quot;#picture2filename#&quot;></CFOUTPUT><br />
</CFIF>
</p>

<CFOUTPUT><input type=&quot;hidden&quot; name=&quot;submitid&quot; value=&quot;#FORM.submitid#&quot;></CFOUTPUT>

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Add to cart&quot;>

</form>
<CFELSE>
<!--- the submitID was found in the list of previously submitted ads... so this submission is not valid --->
You've already submitted this ad. <a href=&quot;page3.cfm&quot;>Click here</a> to view your cart.

</CFIF>
<CFELSE>
<!--- no... the user must've gotten here by mistake (no form was submitted), so take them back to page 1 --->
<CFLOCATION url=&quot;page1.cfm&quot;>
</CFIF>


</body>
</html>

page3.cfm

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>View Shopping Cart</title>
<cfquery name=&quot;get_SubCategories&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
</cfquery>
<cfquery name=&quot;Fees&quot; datasource=&quot;market&quot;>
select *
from Private_Prices
Where category_ID = #form.select_Ad_Subcategory#
</cfquery>
<cfquery name=&quot;GST&quot; datasource=&quot;market&quot;>
select *
from taxes
Where tax = 'gst'
</cfquery>
<cfquery name=&quot;PST&quot; datasource=&quot;market&quot;>
select *
from taxes
Where tax = 'pst'
</cfquery>
<cfset WF = 5>
<cfset MF = 10>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder_Subcat_Select.cfm&quot;>
<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>
<table align=&quot;center&quot;>
<!--- did the user get here from the ad confirmation page? --->
<CFIF IsDefined(&quot;FORM&quot;) AND IsStruct(FORM) AND NOT StructIsEmpty(FORM) AND IsDefined(&quot;FORM.submitid&quot;)>
<CFSET bValidSubmit = true>
<!--- lock the session scope and check the submitID against the list of previously submitted ads... again --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
<CFIF IsDefined(&quot;session.submittedIDs&quot;) AND ListFind(&quot;#session.submittedIDs#&quot;,FORM.submitID) GT 0>
<CFSET bValidSubmit = false>
</CFIF>
</CFLOCK>
<CFIF bValidSubmit>
<cfquery name=&quot;Fees&quot; datasource=&quot;market&quot;>
select * from Private_Prices Where category_ID = #form.select_Ad_Subcategory#
</cfquery>
<cfset WF = 5>
<cfset MF = 10>
<!--- if it's a new submitID, create the temporary structure (NOT in the session scope --->
<CFSET strTempItem = StructNew()>
<!--- listing fees --->
<cfset strtempitem.listing_Fee = #fees.price#>
<cfif form.featured EQ 1 and form.Enddate EQ 7>
<cfset strtempitem.Featured_Fee = #WF#>
<cfelseif form.featured EQ 1 and form.Enddate EQ 30>
<cfset strtempitem.Featured_Fee = #MF#>
<cfelse>
<cfset strtempitem.Featured_Fee = 0>
</cfif>
<cfset strtempitem.categoryid = #form.select_Ad_Subcategory#>
<cfset strtempitem.subcategoryid = #form.selectLocal#>
<cfset strtempitem.subcategory = #form.sub#>
<cfset strtempitem.location = #form.location#>
<cfset strtempitem.itemname = #form.Itemname#>
<cfset strtempitem.Short_Description = #form.Short_Description#>
<cfset strtempitem.long_description = #form.long_description#>
<cfset strtempitem.itemprice = #form.itemprice#>
<cfset strtempitem.featured = #form.featured#>
<cfset strtempitem.begindate = #dateformat(form.begindate, &quot;mm/dd/yyyy&quot;)#>
<cfset strtempitem.Enddate = #dateformat(form.begindate + form.Enddate, &quot;mm/dd/yyyy&quot;)#>
<CFSET strTempItem.picture1 = &quot;&quot;>
<CFSET strTempItem.picture2 = &quot;&quot;>
<CFSET strTempItem.picture3 = &quot;&quot;>
<CFSET strTempItem.picture4 = &quot;&quot;>
<CFIF IsDefined(&quot;FORM.picture1filename&quot;) AND Len(Trim(FORM.picture1filename)) GT 0>
<CFSET strTempItem.picture1 = FORM.picture1filename>
</CFIF>
<CFIF IsDefined(&quot;FORM.picture2filename&quot;) AND Len(Trim(FORM.picture2filename)) GT 0>
<CFSET strTempItem.picture2 = FORM.picture2filename>
</CFIF>
<CFIF IsDefined(&quot;FORM.picture3filename&quot;) AND Len(Trim(FORM.picture3filename)) GT 0>
<CFSET strTempItem.picture3 = FORM.picture3filename>
</CFIF>
<CFIF IsDefined(&quot;FORM.picture4filename&quot;) AND Len(Trim(FORM.picture4filename)) GT 0>
<CFSET strTempItem.picture4 = FORM.picture4filename>
</CFIF>
<!--- then lock the session scope and append the new ad to the shopping cart and update the list of previously submitted IDs with the current submitID --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;EXCLUSIVE&quot; scope=&quot;SESSION&quot;>
<CFIF NOT IsDefined(&quot;session.auth&quot;) or NOT IsArray(session.auth)>
<CFSET session.auth = arraynew(1)>
</CFIF>
<CFSET ArrayAppend(session.auth,strTempItem)>
<CFIF NOT IsDefined(&quot;session.submittedIDs&quot;)>
<CFSET session.submittedIDs = &quot;&quot;>
</CFIF>
<CFSET session.submittedIDs = ListAppend(&quot;#session.submittedIDs#&quot;,FORM.submitID)>
</CFLOCK>
<CFELSE>
<!--- the submitID already exists in the list of previously submitted IDs, so this submission is not valid --->
<tr>
<td><font color=&quot;#FF0000&quot; size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>You've
already added this item to your cart.</font></td>
</tr>
</CFIF>
</CFIF>
<!--- regardless of any of the above, display the current cart --->
<tr>
<td><div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Here's
your shopping cart:</font></div></td>
</tr>
<CFSET aryLocalArray = ArrayNew(1)>
<!--- readonly lock on the session scope, and copy out the session array to a local array... since we really don't want to keep the lock open while we're looping --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
<CFIF IsDefined(&quot;session.auth&quot;) AND IsArray(session.auth)>
<CFSET aryLocalArray = session.auth>
</CFIF>
</CFLOCK>
</table>
<!--- output the cart contents using the local (NOT session scope) array --->
<table border=&quot;0&quot; cellpadding=&quot;5&quot; align=&quot;center&quot;>
<tr bgcolor=&quot;#009933&quot; style=&quot;color: #FFFFFF;&quot;>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Category</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Listing
Fee</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Featured</font></td>
</tr>
<CFIF ArrayLen(aryLocalArray) GT 0>
<cfset variables.totalListing_fee = 0>
<cfset variables.totalFeatured_fee = 0>
<CFLOOP from=&quot;1&quot; to=&quot;#ArrayLen(aryLocalArray)#&quot; index=&quot;whichItem&quot;>
<CFOUTPUT>
<tr>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#whichItem#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#aryLocalArray[whichItem].itemname#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#aryLocalArray[whichItem].subcategoryid#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#dollarformat(aryLocalArray[whichItem].Listing_fee)#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#dollarformat(aryLocalArray[whichItem].Featured_Fee)#</font></td>
<TD><a href=&quot;modify.cfm&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>|Modify|</font></a>  <a href=&quot;Delete.cfm&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>|Delete|</font></a></TD>
</tr>
<cfset totalListing_fee = totalListing_fee + (aryLocalArray[whichItem].Listing_fee)>
<cfset totalFeatured_fee = totalFeatured_fee + (aryLocalArray[whichItem].Featured_Fee)>
</CFOUTPUT>
</CFLOOP>
<cfset Grand_Subtotal = totalListing_fee + totalFeatured_fee>
<cfset Total_GST = Grand_Subtotal * #gst.amount#>
<cfset Total_PST = (Grand_Subtotal + Total_GST) * #PST.amount#>
<cfset Total_taxes = Total_GST + Total_PST>
<cfset Grand_Total = Total_taxes + Grand_Subtotal>
<tr>
<td colspan=&quot;5&quot;><hr></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>SubTotal
Listing Fees</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#Dollarformat(totalListing_fee)#</cfoutput> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>SubTotal
Featured</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><u><cfoutput>#Dollarformat(totalFeatured_fee)#</cfoutput>     </u> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Grand
SubTotal </font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#Dollarformat(Grand_Subtotal)#</cfoutput> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Taxes</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><u><cfoutput>#Dollarformat(Total_Taxes)#</cfoutput>     </u> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Total</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><strong><cfoutput>#Dollarformat(Grand_total)#</cfoutput></strong> </font></td>
<td></td>
</tr>
<CFELSE>
<tr>
<td colspan=&quot;3&quot;>No items currently in cart</td>
</tr>
</CFIF>
</table>
<table align=&quot;center&quot;>
<tr>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><a href=&quot;page1.cfm&quot;>Click
here</a> to add a new item</font></td>
</tr>
</table>



<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>
 
It looks like your code was truncated... so we're not seeing the complete page 3. And, unfortunately, that's where you'd probably be implementing your edit and delete functionality.

Basically... the model is fairly straight-forward. As you're looping through the output of the cart items, you'd build links for each item... borrowing from my example above, you'd do something like:
Code:
<table border=&quot;1&quot; cellpadding=&quot;5&quot;>
<tr bgcolor=&quot;#000000&quot; style=&quot;color: #FFFFFF;&quot;><td>Item #</td><td>Item Name</td><td>Category</td><td></td><td></td></tr>
<CFIF ArrayLen(aryLocalArray) GT 0>
<CFLOOP from=&quot;1&quot; to=&quot;#ArrayLen(aryLocalArray)#&quot; index=&quot;whichItem&quot;>
    <CFOUTPUT><tr><td>#whichItem#</td><td>#aryLocalArray[whichItem].itemname#</td><td>#aryLocalArray[whichItem].category#</td>
Code:
<td><a href=&quot;edit_item.cfm?itemnum=#whichItem#&quot;>edit</a></td><td><a href=&quot;delete_item.cfm?itemnum=#whichItem#&quot;>delete</a></td>
Code:
</tr></CFOUTPUT>
</CFLOOP>
<CFELSE>
    <tr><td colspan=&quot;3&quot;>No items currently in cart</td></tr>
</CFIF>
</table>

Then, edit_item.cfm would simply populate a form that allows the user to edit the item:
Code:
<CFIF IsDefined(&quot;FORM.edititemnum&quot;)>
  <CFLOCK timeout=&quot;30&quot;    
        throwontimeout=&quot;no&quot;
        type=&quot;exclusive&quot;
        scope=&quot;session&quot;>
     <CFSET SESSION.auth2[#FORM.edititemnum#].itemname = FORM.itemname>
     <CFSET SESSION.auth2[#FORM.edititemnum#].category= FORM.category>
        :
        etc.
        :
  </CFLOCK>
  <!--- maybe to a CFLOCATION back to page3 here, if you want --->
<CFELSE>

  <CFSET strEditItem = StructNew()>  
  <CFLOCK timeout=&quot;30&quot;    
        throwontimeout=&quot;no&quot;
        type=&quot;readonly&quot;
        scope=&quot;session&quot;>
     <CFSET strEditItem = SESSION.auth2[#URL.itemnum#]>
  </CFLOCK>

  <form action=&quot;edit_item.cfm&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>
   
  <p><CFOUTPUT>Item name: <input name=&quot;itemname&quot; type=&quot;text&quot; value=&quot;#strEditItem.itemname#&quot;></CFOUTPUT></p>

  <p>Category: 
  <select name=&quot;category&quot;>
  <option value=&quot;&quot;> - SELECT A CATEGORY - </option>
  <CFIF CompareNoCase(strEditItem.category,&quot;1&quot;) EQ 0>
     <option value=&quot;1&quot; SELECTED>
  <CFELSE>
     <option value=&quot;1&quot;>
  </CFIF>Category 1</option>
  <CFIF CompareNoCase(strEditItem.category,&quot;2&quot;) EQ 0>
     <option value=&quot;2&quot; SELECTED>
  <CFELSE>
     <option value=&quot;2&quot;>
  </CFIF>Category 2</option></select>
  </p>
     :
     :
  <CFOUTPUT><input type=&quot;hidden&quot; name=&quot;edititemnum&quot; value=&quot;#URL.itemnum#&quot;></CFOUTPUT>

  <input type=&quot;submit&quot;>
  </form>
</CFIF>

and the delete page would be even easier:
Code:
<CFIF IsDefined(&quot;FORM.edititemnum&quot;)>
  <CFLOCK timeout=&quot;30&quot;    
        throwontimeout=&quot;no&quot;
        type=&quot;exclusive&quot;
        scope=&quot;session&quot;>
     <CFSET ArrayDeleteAt(SESSION.auth2,FORM.edititemnum)>
  </CFLOCK>
  <!--- maybe to a CFLOCATION back to page3 here, if you want --->
<CFELSE>

  <CFSET strEditItem = StructNew()>  
  <CFLOCK timeout=&quot;30&quot;    
        throwontimeout=&quot;no&quot;
        type=&quot;readonly&quot;
        scope=&quot;session&quot;>
     <CFSET strEditItem = SESSION.auth2[#URL.itemnum#]>
  </CFLOCK>

  <form action=&quot;edit_item.cfm&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>
  <p>Do you really want to delete the item
<CFOUTPUT>#strEditItem.itemname#</CFOUTPUT>?</p>

  <CFOUTPUT><input type=&quot;hidden&quot; name=&quot;edititemnum&quot; value=&quot;#URL.itemnum#&quot;></CFOUTPUT>

  <input type=&quot;submit&quot; value=&quot;Yes&quot;>
  </form>
</CFIF>

I just can't emphasize enough that you should really buy (and thoroughly read) a ColdFusion book (Web Application Construction Kit, for example, details building several different types of shopping carts). The fact that the code we're discussing is still &quot;a little hairy&quot; to you is a clear warning signal that you're probably not prepared enough to move forward. While you might be able to get away with cut-and-paste solutions with something like javascript, you really need to know your CFML inside and out in order to build, and more importantly customize, revise and maintain it in the future.


-Carl
 
Carl,

Thanks again. I just finished school and I took computers (a+, MCP, Networking and computer applications). The company that I started working for is affiliated with the school, hench partly why I got the job. During my OJT I designed a database for the staff to track students, any thing that they needed to know about the students. It was done with Coldfusion and SQL. It impressed the manager. Now he wants an online classified ads site developed and it is entirley my project. I love everything about computers, and they know that, but in the 5-6 years that I had one (stupid me never looked at a piece of code, never made a page or anything). Well here it is about four months into my job and I am coding, I did get a couple of books (Teach Yourself Coldfusion in 24 days, Coldfuaion Bible, Web Application Construction Kit, and Core Coldfusion). As you can see no shortage of reading material. The problem being that the project that I am working on, he wants done by christmas and he thinks that after the student database, I should know all there is to know about Coldfusion (as yoiu can see, not the case). I am finding it hard to fit in studing. So as you can see the predicument that i am in, i really do appriciate the help you have given me so far. I do know a little coldfusion but not enough.

Maybe we could comunicate through email, that may be easier and that way I can send you the pages instead of cutting and pasting.

sbanks@northstarpei.com

If there is anything that I can do for you, let me know. I am proficiant in Microsoft Office and Adobe PhotoShop, and I have a coworker that knows quite a lot about computers aswell. thanks

 
Thanks Shawn. I'm pretty proficient on the computer already, but I'll keep you in mind.


If you already have Web Application Construction Kit, might I turn your attention to pages 807-827. Literally 20 whole pages that talk about the considerations for designing a shopping cart, and how to build one. The included CD-ROM has a couple of examples (CF_MX_WACK:\ows\27\), and even contains the ShoppingCart CFC component that they discuss (which, alone, is probably worth 10x the price of the book... it contains functions to add, update and delete items... all the things we've been talking about here).

We've all been where you are now... faced with ridiculous deadlines on a project that's somewhat foreign in scope... but, trust me, diving straight into the code is not the way to get it done. A tight deadline is no excuse for short-cutting the design process... quite the contrary; the tighter the deadline, the more festidious you have to be with your upfront design roadmap... and the more researched your design decisions have got to be.

We could communicate via email, sending pages back and forth until you have something that's completely working (maybe even before your deadline). But I'm not really looking to be the one who writes all your code for you or solves all your problems. I'm a huge proponent of teaching someone to fish, rather than handing them a plateful of salmon. And so far, I'm really only seeing you polishing your plater, and not casting your line (okay... Carl's Late-night Case #62 of &quot;Carrying a metaphor too far&quot;).



-Carl
 
I looked in my web application construction kit and come to find out I must have a different version, I have &quot;The Macromedia Coldfusion 5 - Web Application Construction Kit&quot;, in there i did read over the shopping cart application, and I found it no use. It seems to me that all shopping carts that I have seen deal with a store selling merchandise, so you browes the categories and hit add to cart. I find with my application I have alot of variable that have to be put into the shopping cart and I need it to do special things like 2 drop downs that are linked to one another, and adding pictures to a database(folder)and so on. I understand where you are comming from, I have been taking a lot of handouts from you. I really could use your help. If you would rather not thats ok.
 
Are you running CF 5.0, or MX? The WACK I have is, indeed, ColdFusion MX. If you're running MX, I'd definitely recommend you update the book... because a great deal has changed.

If you're running CF 5.0, then, obviously, the new version of the book won't help you all that much.


While your shopping cart is storing information that, more than likely, an example will not show, example shopping carts do store information. And extending them to store the information you require is simply a matter of analyzing how they store the data they do store, and adding your own data in it's place.

Whether the subject matter is merchandise, or classified ads, it's really the same model underneath. We've already talked about how to store all the information you need in your cart (the array of structures... pretty much the same as if I were trying to store merchandise), and how to add images (or, at least filenames... it's generally a bad idea to add the actual images) to your database.

One of the things you need to understand is degrees of &quot;separation&quot; (or, perhaps, &quot;abstraction&quot;). You really want to build ColdFusion apps modularly... if not for your sanity's sake, then for the sake of porting those modules to future projects. The &quot;shopping cart&quot; module, for example, should only be concerned with adding and maintaining data about a user's order (which is why the CFC in the MX WACK is so great... but it only works under MX). It shouldn't really care about what data you're storing to it... it should just care about indexing it, and making sure it can get at it when you tell it to edit that data.

The 2 dropdowns that are linked to one another... that's not really a function of the &quot;shopping cart&quot;. That would be a different component of your application (say, the &quot;user interface&quot; module). And, in order to accomplish that, you'd want to use a combination of a query (to grab the possible values of each dropdown) and javascript (to dynamically switch out valid values based on whatever criteria). As an example of abstraction, we actually built a custom tag called &quot;CF_LINKEDLISTS&quot; which generically builds any number of dropdowns based on a query that I pass in as an attribute, all linked so that, when you select a value in one, it populates the correct items in the next. So, when we need a linked list, the code in that tag is abstracted enough (it doesn't care about the context) that it can be called from wherever.

I'm happy to answer whatever questions you have, or help with any errors you're getting... but, like I said, I don't think I'm keen on writing the whole thing for you.

To that end, as I said, we've already discussed how your shopping cart adds and stores items, as well as how to edit and delete items. At this point, it's a little unclear as what further issues are on the table.
Are you getting errors? Or ... ??


-Carl
 
Hi Carl,

I think that I have completed most of the cart now execpt the checkout process. I was wondering if you might take a moment and look over the code and see if there are any problems.

Page 1, and page 2 have not changed.

Page3.cfm

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>View Shopping Cart</title>
<cfquery name=&quot;get_SubCategories&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
</cfquery>
<cfparam name=&quot;form.select_Ad_Subcategory&quot; default=&quot;1&quot;>
<cfquery name=&quot;Fees&quot; datasource=&quot;market&quot;>
select *
from Private_Prices
Where category_ID = #form.select_Ad_Subcategory#
</cfquery>
<cfquery name=&quot;GST&quot; datasource=&quot;market&quot;>
select *
from taxes
Where tax = 'gst'
</cfquery>
<cfquery name=&quot;PST&quot; datasource=&quot;market&quot;>
select *
from taxes
Where tax = 'pst'
</cfquery>
<cfset WF = 5>
<cfset MF = 10>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder_Subcat_Select.cfm&quot;>
<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>
<table align=&quot;center&quot;>
<!--- did the user get here from the ad confirmation page? --->
<CFIF IsDefined(&quot;FORM&quot;) AND IsStruct(FORM) AND NOT StructIsEmpty(FORM) AND IsDefined(&quot;FORM.submitid&quot;)>
<CFSET bValidSubmit = true>
<!--- lock the session scope and check the submitID against the list of previously submitted ads... again --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
<CFIF IsDefined(&quot;session.submittedIDs&quot;) AND ListFind(&quot;#session.submittedIDs#&quot;,FORM.submitID) GT 0>
<CFSET bValidSubmit = false>
</CFIF>
</CFLOCK>
<CFIF bValidSubmit>
<cfquery name=&quot;Fees&quot; datasource=&quot;market&quot;>
select * from Private_Prices Where category_ID = #form.select_Ad_Subcategory#
</cfquery>
<cfset WF = 5>
<cfset MF = 10>
<!--- if it's a new submitID, create the temporary structure (NOT in the session scope --->
<CFSET strTempItem = StructNew()>

<cfset strtempitem.submitID = form.submitID>
<cfset strtempitem.categoryid = #form.select_Ad_Subcategory#>
<cfset strtempitem.subcategoryid = #form.selectLocal#>
<cfset strtempitem.subcategory = #form.sub#>
<cfset strtempitem.location = #form.location#>
<cfset strtempitem.itemname = #form.Itemname#>
<cfset strtempitem.Short_Description = #form.Short_Description#>
<cfset strtempitem.long_description = #form.long_description#>
<cfset strtempitem.itemprice = #form.itemprice#>
<cfset strtempitem.featured = #form.featured#>
<cfset strtempitem.begindate = #dateformat(form.begindate, &quot;mm/dd/yyyy&quot;)#>
<cfset strtempitem.Enddate = #dateformat(form.begindate + form.Enddate, &quot;mm/dd/yyyy&quot;)#>
<CFSET strTempItem.picture1 = &quot;&quot;>
<CFSET strTempItem.picture2 = &quot;&quot;>
<CFSET strTempItem.picture3 = &quot;&quot;>
<CFSET strTempItem.picture4 = &quot;&quot;>
<CFIF IsDefined(&quot;FORM.picture1filename&quot;) AND Len(Trim(FORM.picture1filename)) GT 0>
<CFSET strTempItem.picture1 = FORM.picture1filename>
</CFIF>
<CFIF IsDefined(&quot;FORM.picture2filename&quot;) AND Len(Trim(FORM.picture2filename)) GT 0>
<CFSET strTempItem.picture2 = FORM.picture2filename>
</CFIF>
<CFIF IsDefined(&quot;FORM.picture3filename&quot;) AND Len(Trim(FORM.picture3filename)) GT 0>
<CFSET strTempItem.picture3 = FORM.picture3filename>
</CFIF>
<CFIF IsDefined(&quot;FORM.picture4filename&quot;) AND Len(Trim(FORM.picture4filename)) GT 0>
<CFSET strTempItem.picture4 = FORM.picture4filename>
</CFIF>
<!--- then lock the session scope and append the new ad to the shopping cart and update the list of previously submitted IDs with the current submitID --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;EXCLUSIVE&quot; scope=&quot;SESSION&quot;>
<CFIF NOT IsDefined(&quot;session.auth&quot;) or NOT IsArray(session.auth)>
<CFSET session.auth = arraynew(1)>
</CFIF>
<CFSET ArrayAppend(session.auth,strTempItem)>
<CFIF NOT IsDefined(&quot;session.submittedIDs&quot;)>
<CFSET session.submittedIDs = &quot;&quot;>
</CFIF>
<CFSET session.submittedIDs = ListAppend(&quot;#session.submittedIDs#&quot;,FORM.submitID)>
</CFLOCK>
<CFELSE>
<!--- the submitID already exists in the list of previously submitted IDs, so this submission is not valid --->
<tr>
<td><font color=&quot;#FF0000&quot; size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>You've
already added this item to your cart.</font></td>
</tr>
</CFIF>
</CFIF>
<!--- regardless of any of the above, display the current cart --->
<tr>
<td><div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Here's
your shopping cart:</font></div></td>
</tr>
<CFSET aryLocalArray = ArrayNew(1)>
<!--- readonly lock on the session scope, and copy out the session array to a local array... since we really don't want to keep the lock open while we're looping --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
<CFIF IsDefined(&quot;session.auth&quot;) AND IsArray(session.auth)>
<CFSET aryLocalArray = session.auth>
</CFIF>
</CFLOCK>

</table>
<!--- output the cart contents using the local (NOT session scope) array --->
<table border=&quot;0&quot; cellpadding=&quot;5&quot; align=&quot;center&quot;>
<tr bgcolor=&quot;#009933&quot; style=&quot;color: #FFFFFF;&quot;>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Category</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Listing
Fee</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Featured</font></td>
</tr>
<CFIF ArrayLen(aryLocalArray) GT 0>
<cfset variables.totalListing_fee = 0>
<cfset variables.totalFeatured_fee = 0>
<CFLOOP from=&quot;1&quot; to=&quot;#ArrayLen(aryLocalArray)#&quot; index=&quot;whichItem&quot;>
<cfquery name=&quot;Get_Cat&quot; datasource=&quot;market&quot;>
select Subcategory
from subcategory
Where subcategoryID = #aryLocalArray[whichItem].subcategoryid#
</cfquery>
<cfquery name=&quot;Fees&quot; datasource=&quot;market&quot;>
select * from Private_Prices Where category_ID = #aryLocalArray[whichItem].categoryid#
</cfquery>
<cfquery name=&quot;FFEEs&quot; datasource=&quot;market&quot;>
select Price * 0.40 as feat_total
from Private_Prices
Where category_ID = #aryLocalArray[whichItem].categoryid#
</cfquery>

<CFOUTPUT>
<tr>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#whichItem#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><a href=&quot;Review.cfm?itemnum=#whichItem#&quot;>#aryLocalArray[whichItem].itemname#</a></font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#get_cat.subcategory#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#dollarformat(fees.price)#</font></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfif aryLocalArray[whichItem].Featured EQ 1>#dollarformat(ffees.feat_total)#</font></cfif></td>
<TD><a href=&quot;edit_item.cfm?itemnum=#whichItem#&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>|Modify|</font></a>  <a href=&quot;delete_item.cfm?itemnum=#whichItem#&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>|Delete|</font></a></TD>
</tr>

<cfset totalListing_fee = totalListing_fee + fees.price>
<cfif aryLocalArray[whichItem].Featured EQ 1>
<cfset totalFeatured_fee = totalFeatured_fee + FFEEs.feat_total></cfif>
</CFOUTPUT>
</CFLOOP>
<cfset Grand_Subtotal = totalListing_fee + totalFeatured_fee>
<cfset Total_GST = Grand_Subtotal * #gst.amount#>
<cfset Total_PST = (Grand_Subtotal + Total_GST) * #PST.amount#>
<cfset Total_taxes = Total_GST + Total_PST>
<cfset Grand_Total = Total_taxes + Grand_Subtotal>
<tr>
<td colspan=&quot;6&quot;><hr></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>SubTotal
Listing Fees</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#Dollarformat(totalListing_fee)#</cfoutput> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>SubTotal
Featured</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><u><cfoutput>#Dollarformat(totalFeatured_fee)#</cfoutput>     </u> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Grand
SubTotal </font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#Dollarformat(Grand_Subtotal)#</cfoutput> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Taxes</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><u><cfoutput>#Dollarformat(Total_Taxes)#</cfoutput>     </u> </font></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Total</font></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><strong><cfoutput>#Dollarformat(Grand_total)#</cfoutput></strong> </font></td>
<td></td>
</tr>
<CFELSE>
<tr>
<td colspan=&quot;3&quot;>No items currently in cart</td>
</tr>
</CFIF>
</table>
<table align=&quot;center&quot; border=&quot;0&quot;>
<tr><td colspan=&quot;2&quot;><hr></td></tr>
<tr>
<td width=&quot;200&quot;><div align=&quot;center&quot;><a href=&quot;page1.cfm&quot;><img src=&quot;../images/new_item.gif&quot; border=&quot;0&quot;></a></div></td>
<td width=&quot;200&quot;><div align=&quot;center&quot;><a href=&quot;Checkout.cfm&quot;><img src=&quot;../images/checkout.gif&quot; border=&quot;0&quot;></a></div></td>
</tr>
</table>
<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>

edit_item.cfm

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<cfquery name=&quot;get_Communities&quot; datasource=&quot;Market&quot;>
SELECT *
FROM Communities
order by location
</cfquery>

<cfquery name=&quot;get_SubCategories&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat

</cfquery>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder_Subcat_Select.cfm&quot;>
<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>
<CFIF IsDefined(&quot;FORM.edititemnum&quot;)>

<CFLOCK timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;exclusive&quot;
scope=&quot;session&quot;>
<CFSET SESSION.auth[#FORM.edititemnum#].itemname = FORM.itemname>
<CFSET SESSION.auth[#FORM.edititemnum#].categoryid = FORM.select_Ad_Subcategory>
<CFSET SESSION.auth[#FORM.edititemnum#].subcategoryid = FORM.selectLocal>
<CFSET SESSION.auth[#FORM.edititemnum#].location = FORM.Community_List>
<CFSET SESSION.auth[#FORM.edititemnum#].Short_Description = FORM.Short_Description>
<CFSET SESSION.auth[#FORM.edititemnum#].long_description = FORM.long_description>
<CFSET SESSION.auth[#FORM.edititemnum#].itemprice = FORM.itemprice>
<CFSET SESSION.auth[#FORM.edititemnum#].featured = FORM.featured>
<CFSET SESSION.auth[#FORM.edititemnum#].begindate = FORM.begindate>
<CFSET SESSION.auth[#FORM.edititemnum#].enddate = FORM.begindate + FORM.enddate>


</CFLOCK>
<!--- maybe to a CFLOCATION back to page3 here, if you want --->
<cflocation url=&quot;Page3.cfm&quot;>
<CFELSE>

<CFSET strEditItem = StructNew()>
<CFLOCK timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;readonly&quot;
scope=&quot;session&quot;>
<CFSET strEditItem = SESSION.auth[#URL.itemnum#]>
</CFLOCK>
<!---<cfif isdefined (&quot;url.itemnum&quot;)></cfif> --->
<cfquery name=&quot;get_cat&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
where subcategoryid = #SESSION.auth[URL.itemnum].subcategoryid#
</cfquery>

<cfform action=&quot;edit_item.cfm&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>

<table align=&quot;center&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;5&quot; class=&quot;FormHeaders&quot;><div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><!--- <cfoutput>#categories.Category#</cfoutput> --->
Details</font></div></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Category:</font></td>
<td valign=&quot;top&quot; colspan=&quot;4&quot;>
<select name=&quot;select_Ad_Subcategory&quot; onchange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<cfoutput><option value=&quot;#get_cat.categoryid#&quot;>#get_cat.category#</option></cfoutput>
<!--- again, use the group attribute to group output by category --->
<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<option value=&quot;#Categoryid#&quot;>#Category#</option>
</cfoutput>
</select></td></tr>
<tr><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Subcategory:</font></td>
<td colspan=&quot;4&quot;> <select name=&quot;selectLocal&quot; onChange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<cfoutput><option value=&quot;#get_cat.subcategoryid#&quot;>#get_cat.subcategory#</option></cfoutput>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>

<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Community:</font></td>
<td colspan=&quot;4&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>
<select name=&quot;Community_List&quot;>

<option><cfoutput>#strEditItem.location#</cfoutput></option>
<cfoutput query=&quot;Get_Communities&quot;>
<option value=&quot;#location#&quot;>#location#</option>
</cfoutput>
</select>
</font></td>
</tr>
<tr>
<td width=&quot;109&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name:</font></td>
<td colspan=&quot;4&quot;> <font face=&quot;Georgia, Times New Roman, Times, serif&quot;>

<CFinput name=&quot;Itemname&quot; type=&quot;text&quot; required=&quot;no&quot; message=&quot;Item Name Required&quot; value=&quot;#strEditItem.itemname#&quot;>
</font></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Short
Description:</font></td>
<td colspan=&quot;4&quot;>
<textarea name=&quot;Short_description&quot; cols=&quot;30&quot; rows=&quot;5&quot; wrap=&quot;hard&quot; onChange=&quot;if (this.value.length > 100) {alert('The Short Description Cannot Be Greater Than 100 Chars.')};&quot;><cfoutput>#strEditItem.short_description#</cfoutput></textarea>

</td>
</tr>
<tr>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Long
Description:</font></td>
<td colspan=&quot;4&quot;><textarea name=&quot;Long_description&quot; cols=&quot;30&quot; rows=&quot;5&quot;><cfoutput>#strEditItem.long_description#</cfoutput></textarea>

</td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Asking
Price:</font></td>
<td colspan=&quot;4&quot;><CFinput name=&quot;itemprice&quot; value=&quot;#strEditItem.itemprice#&quot; type=&quot;text&quot; id=&quot;itemprice&quot; required=&quot;no&quot; message=&quot;Asking Price Required&quot; size=&quot;20&quot; maxlength=&quot;9&quot;>

</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><span >Featured
Item</span><font color=&quot;#FF0000&quot;>*</font></font></td>
<td colspan=&quot;4&quot;> <cfif strEditItem.Featured EQ 1><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot;checked=&quot;yes&quot;> <cfelse><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot;></cfif>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Yes</font> </td>
<tr><td> </td><td colspan=&quot;4&quot;> <cfif strEditItem.Featured EQ 0><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot; checked=&quot;yes&quot;> <cfelse><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot;></cfif>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>No</font> </td></tr>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Start
Date Of Ad:</font></td>
<td colspan=&quot;4&quot;><cfinput name=&quot;begindate&quot; type=&quot;text&quot; validate=&quot;date&quot; value=&quot;#strEditItem.begindate#&quot;>
</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Length
Of Ad:</font></td>
<td><cfif strEditItem.Enddate EQ strEditItem.begindate + 7><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot; checked=&quot;yes&quot;><cfelse><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot;></cfif></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>7
Days</font></td>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;> </font></td>
<td><cfif strEditItem.Enddate EQ strEditItem.begindate + 30><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot; checked=&quot;yes&quot;><cfelse><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot;></cfif></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>30 Days
</font></td>
</tr></table>

<table align=&quot;center&quot; border=&quot;0&quot;>

<tr bgcolor=&quot;#FFFFFF&quot;>
<td colspan=&quot;5&quot;><div align=&quot;center&quot;> <CFOUTPUT><input type=&quot;hidden&quot; name=&quot;edititemnum&quot; value=&quot;#URL.itemnum#&quot;></CFOUTPUT>
<input type=&quot;submit&quot; value=&quot;Continue >>&quot;>
</div></td>
</tr>
</table>


</cfform>

</CFIF>

<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top