alexanderax
asked on
if-else statement for coldfusion
I'm a newbie on coldfusion so please someone help me.
<CFset today = NOW()>
<cfif not isDefined("Form.fileupload") OR Form.fileupload EQ "">
<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</cfquery>
<cfelseif>
<cffile action="upload"
filefield="fileupload"
destination="d:\intranet_info\sharing\shared_x\newsharex\2007\"
nameconflict="overwrite">
<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</cfquery>
<cfelseif>
<cffile action="upload"
filefield="fileupload"
destination="d:\intranet_info\sharing\shared_x\newsharex\2007\"
nameconflict="overwrite">
<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</cfquery>
</cfif>
ASKER
But is there any other ways to use the above statement? I want it to be like when user upload the file into the database, it will automatic updated in the database and it's particular folder(example like 2007 folder, 2008 folder etc..)when uploading excel or pdf file into each of the folder. Below is a must include ccondition after those statement in bold and underlined.
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
(FIRST condition)
filefield="fileupload"
destination="d:\intranet_i nfo\sharin g\shared_x \newsharex \2007\"
nameconflict="overwrite">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
(second condition)
filefield="fileupload"
destination="d:\intranet_i nfo\sharin g\shared_x \newsharex \2008\"
nameconflict="overwrite">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
(FIRST condition)
filefield="fileupload"
destination="d:\intranet_i
nameconflict="overwrite">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
(second condition)
filefield="fileupload"
destination="d:\intranet_i
nameconflict="overwrite">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
ASKER
But is there any other ways to use the above statement? I want it to be like when user upload the file into the database, it will automatic updated in the database and it's particular folder(example like 2007 folder, 2008 folder etc..)when uploading excel or pdf file into each of the folder. Below is a must include ccondition after those statement in bold and underlined.
just now did not underline the top few sentence..
<cfif not isDefined("Form.fileupload ") OR Form.fileupload EQ "">
<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</cfquery>
(FIRST condition)
<CFFILE
filefield="fileupload"
destination="d:\intranet_i nfo\sharin g\shared_x \newsharex \2007\"
nameconflict="overwrite">
<CFQUERY datasource="technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</CFQUERY>
(second condition)
<CFFILE
filefield="fileupload"
destination="d:\intranet_i nfo\sharin g\shared_x \newsharex \2008\"
nameconflict="overwrite">
<CFQUERY datasource="technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</CFQUERY
just now did not underline the top few sentence..
<cfif not isDefined("Form.fileupload
<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</cfquery>
(FIRST condition)
<CFFILE
filefield="fileupload"
destination="d:\intranet_i
nameconflict="overwrite">
<CFQUERY datasource="technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</CFQUERY>
(second condition)
<CFFILE
filefield="fileupload"
destination="d:\intranet_i
nameconflict="overwrite">
<CFQUERY datasource="technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</CFQUERY
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks SidFishes for the solution. now i still got another problems. i now trying to develop an web-base search engine. i'm not sure why i when i input numbers in the text box, there's no results shown or that particular file was not shown.
ASKER
Hi SidFishes, recently i found out that when i uploaded my files, it can be successfully uploaded BUT when i click new upload for new author again, the folder that the files should be saving inside, "overwrite" my current file that's been uploaded previously and same goes to updating. Example: Like when i UPLOAD "rash.xsl", it WILL save the excel file to the 2008 folder but when i go to my edit page and click browse to upload the "rash.xsl" file again (assuming that i already updated the rash.xsl), and i click on the "UPDATE" button, the 2008 folder suppose to have this "rash.xsl" with the updated version but instead the files DISAPPEAR!! But if i browse and upload another files like "new.xsl", that particular files will still be saved to the 2008 folder together with the old VERSION rash.xsl files. All i know is that same filename will disappear but diffenert won't. Want i want is to be able to update older excel/word/pdf etc files instead of keep deleting the old one then upload the new one up. May i know why is this happening?
<cfif value eq 1>
do something
<cfelseif value eq 2>
do something different
<cfelseif value eq 3>
do something different again>
<cfelse>
otherwise do this
</cfif>