Question
loop query
Hi i have a payment table, when a user pays for our service
the details get inserted into.
I have ClientID, Amount, CostPerUnit as my columns
say i have the clientID as 34 who has an Amount of 1000 and a PerUnit is 0.12
and the i have the same client 34 with Amount of 250 and a PerUnit is 0.17
what i need to do is insert the perunit cost into my records table everytime a unit has been used
ie
<cfquery datasource="#application.ds#">
insert into Records
(CientID, Cost, ClientCostPerSMS)
values
('#session.ClubLogin#', 1', UNITCOST)
</cfquery>
but before i insert it i need to know which unit cost to insert, so i have a session which tells me how many uints they have left
'#session.TotalSMSLeft#'
how can i have a query which selects the first record by ClientID and if the '#session.TotalSMSLeft#' is more than the Amount to select the next record an so on....
<CFQUERY datasource="#application.ds#" Name="GetPayInfo">
SELECT *
FROM payment_table
WHERE ClientID = #ClientIDD#
</cfquery>
I have ClientID, Amount, CostPerUnit as my columns
say i have the clientID as 34 who has an Amount of 1000 and a PerUnit is 0.12
and the i have the same client 34 with Amount of 250 and a PerUnit is 0.17
what i need to do is insert the perunit cost into my records table everytime a unit has been used
ie
<cfquery datasource="#application.ds#">
insert into Records
(CientID, Cost, ClientCostPerSMS)
values
('#session.ClubLogin#', 1', UNITCOST)
</cfquery>
but before i insert it i need to know which unit cost to insert, so i have a session which tells me how many uints they have left
'#session.TotalSMSLeft#'
how can i have a query which selects the first record by ClientID and if the '#session.TotalSMSLeft#' is more than the Amount to select the next record an so on....
<CFQUERY datasource="#application.ds#" Name="GetPayInfo">
SELECT *
FROM payment_table
WHERE ClientID = #ClientIDD#
</cfquery>