Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating array in coldfusion

How would I create an array that will return data in the following format via CF 8?

This information originates from an order table based on SKU value and QTY. I already know the query to use to pull the data. I just would like some help to format it.

The original data exists in the following format

SKU82328  QTY 1
SKU9832   QTY 3
SKU8923   QTY 1

skulist=SKU82328,SKU9832,SKU8923&quantitylist=1,3,1
like image 586
jeff Avatar asked Jul 03 '26 11:07

jeff


1 Answers

<cfquery name"SkuQuery" datasource="DSN">
  SELECT sku, quantity FROM someTable WHERE someCondition = 'true'
</cfquery>

<cfset SkuList      = ValueList(SkuQuery.sku)>
<cfset QuantityList = ValueList(SkuQuery.quantity)>

<cfset QueryString = "skulist=#URLEncodedFormat(SkuList)#&quantitylist=#URLEncodedFormat(QuantityList)#">
like image 72
Tomalak Avatar answered Jul 05 '26 16:07

Tomalak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!