?
Solved

Data Manipulation

Posted on 2003-03-23
6
Medium Priority
?
133 Views
Last Modified: 2013-12-24
I am currently working on a project which requires me to "sort" out the data that i retreive from a list. Here is what i have on the action page:

<CFinput type="checkbox" name="processing" value="#OrderNo#, #ProductNo#">
     <INPUT type="hidden" name="ProductNo" value="#GetInfo.ProductNo#">
     <INPUT type="hidden" name="OrderNo" value="#GetInfo.OrderNo#">

I have created a checkbox. For each order, there can be many items. When the selected checkboxes are checked, it will bring me to the action page. I have created a list on the action page which looks like this:

<cfloop index="check2" list="#form.cooking#">

  After this, I have to update the database according to the order number and product number. Currently, if i have 1 order and 2 items in that order my list will look like this "1,1,1,2". What i need is to sort out the data and update a table in the database. With the list i have now, the database would not be able to understand that order 1 has 2 items numbered product 1 and product 2.

  Thanks in advance to anybody who will spare some time to read the problem and help me out..
0
Comment
Question by:TBB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
anandkp earned 200 total points
ID: 8193593
change ur code to something like this
<CFinput type="checkbox" name="processing" value="#OrderNo#~#ProductNo#">

now ur list will become - "1~1,1~2"

using listsort get all the order in sorted manner

run a loop on this "," as delimeter & insert them in DB with then using "~" as the delimeter

so which is order no & whihc is itemno becomes obvious !

let me know

K'Rgds
Anand
0
 

Author Comment

by:TBB
ID: 8195203
I managed to make my list now to become "1~1,1~2" after modifying the list I created earlier and using the ~ as you told me to. Thanks for that.

This is the list that I have now in my action page:
<cfloop index="check2" list="#form.processing#" delimiters="check_delimiter">

However, I am trying to update the database. Sorry for not elaborating earlier. My database has a column name "processing" and data type is yes/no. I need to update the items table by using the list. I cant use delimeter to insert the data in the database as you mention. How do i write the "where" code so that the DB can be updated accordingly

<cfquery name="CreateFav" datasource="#application.DSN#">
Update Items
     set
     Items.processing = Yes
        Where ....
</cfquery>

Hope you can understand what i am trying to say.

Thanks again.
TBB
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8200300
This shld be easy using listgtat()

i'll give a eg on how to use listgetat fucntions to suit ur needs
assuming
<cfset x = "1,2~2,2">

use listgtat(x,1,'~') - this will give u "1,2"
again use listgetat to determine the value of element u want from this list [1,2]
using this u can update it to yes/no

i am not able to put a eg u want as i dont know - how ur query strcture is wrt teh form elemets ...

but i hope this wld give u some idea on how to go abt doing it

let me know - if u need more help

K'Rgds
Anand
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 10

Expert Comment

by:substand
ID: 8216171
i'm not completely sure what you are trying to do... but I'll give it a shot:

<cfif listlen(form.processing) gt 0>
<cfset count=1>

<cfquery name="update" datasource="yourDSN">
update Items
set Items.processing = Yes
where
<cfloop list="#form.processing#" index="orderproduct">
<cfset count=count+1>
(ordernum=#listgetat(orderproduct,1,'~')# and productnum=#listgetat(orderproduct,2,'~')#)
<cfif listlen(form.processing) is not count> or </cfif>
</cfquery>

</cfif>

0
 

Author Comment

by:TBB
ID: 8217948
I think i got what i wanted already. I didnt exactly use what u mentioned but the part about using ~ as the delimeter and sorting the list were quite helpful. Thanks a lot anandkp :)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 8222629
ok - i hope it got u thru with this ...

else let me know

K'Rgds
Anand
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question