Increment a Hidden Column value by +1 each time..


i have following code segment & need add in third column called ttcount that needs incremented "1"

- starts out value of "1" (when ticket created..)

- if/when ticket "re-opened", needs incremented +1

 

so, question how alter code below update ttcount field 1?

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

<!--- hold off doing update unless the form has been submitted --->

<cfif isdefined("form.kt_insert1")>

<!--- update status re-opened , owner unassigned in tbltickets table --->

      <cfquery datasource="care">  

    update tbltickets

set ttstatus=<cfqueryparam value="re-opened" cfsqltype="cf_sql_varchar">,

    ttowner=<cfqueryparam value="unassigned" cfsqltype="cf_sql_varchar">

where ttnum=<cfqueryparam cfsqltype="cf_sql_varchar" value="#url.id#">

  </cfquery>

</cfif>

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

 

note: ttcount field hidden field follows:

<input type="hidden" name="ttcount" id="ttcount" value="1" />

i figured out using following code in bold:

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

<!--- hold off doing update unless the form has been submitted --->

<cfif isdefined("form.kt_insert1")>

<!--- update status re-opened , owner unassigned in tbltickets table --->

      <cfquery datasource="care">  

    update tbltickets

set ttstatus=<cfqueryparam value="re-opened" cfsqltype="cf_sql_varchar">,

    ttowner=<cfqueryparam value="unassigned" cfsqltype="cf_sql_varchar">

   , ttcount=<cfif isdefined("form.ttcount") , #form.ttcount# neq "">

<cfqueryparam value="#form.ttcount#" cfsqltype="cf_sql_numeric">+1

<cfelse>

null

</cfif>

where ttnum=<cfqueryparam cfsqltype="cf_sql_varchar" value="#url.id#">

  </cfquery>

</cfif>    

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



More discussions in ColdFusion


adobe

Comments

Popular posts from this blog

Warning, the Safe Path is not accessible vm3 - Joomla! Forum - community, help and support

2.5.28 to 3.4.1---Download of update package failed - Joomla! Forum - community, help and support

Your host needs to use PHP 5.3.10 or higher to run this vers - Joomla! Forum - community, help and support