rado
Posts: 221
|
| Posted: 10/17/2009, 10:59 AM |
|
I have need to go trough records and retrieve "all types" into one variable.
I tried with this code but it doesn't work. Any idea where I made error?
==============================================================================
$sql ="SELECT * FROM payments WHERE payments_TransParentID = payments_TransactionID";
$db->query($sql);
$cumulative_payment_types = "";
$db->query($sql);
while ($db->next_record()) {
$payment_type = $db->f("payments_Type");
$cumulative_payment_types = $cumulative_payment_types .",". $payment_type;
}
==============================================================================
If query succeed I should get variable with this value "type1, type2, type3..."
Thanks,
Rado
|
 |
 |
Zye
Posts: 56
|
| Posted: 10/17/2009, 11:11 AM |
|
Hi Rado
I just noticed in passing that you have $ missing on the last line - maybe.
$cumulative_payment_types = cumulative_payment_types .",". $payment_type;
$cumulative_payment_types = $cumulative_payment_types .",". $payment_type;
|
 |
 |
rado
Posts: 221
|
| Posted: 10/17/2009, 12:18 PM |
|
Thanks,
That was mistake when I typed this topic. In my original script the "$" is there.
Rado
|
 |
 |
rado
Posts: 221
|
| Posted: 10/17/2009, 1:00 PM |
|
I found that this while loop return data, however the additional sql query doesn't work.
1.Original Query
$sql ="UPDATE payments SET payments_Amount = $total_amount, payments_TypeCum = $cumulative_payment_types WHERE payments_TransactionID = $payments_TransactionID";
When I debug the sql query I got this :
UPDATE payments SET payments_Amount = 1299, cumulative_payment_types = Sublet Charge,Bounced Check Fee (NSF),Damage Charges,Interest,Credit,Key Deposit, WHERE payments_TransactionID = 441
I need to have all valuse for $cumulative_payment_types" column set in quotes, but I don't know how I can do that in "1.Original Query"
|
 |
 |
rado
Posts: 221
|
| Posted: 10/17/2009, 1:16 PM |
|
It's solved.
Before I run last query I set this:
$cumulative_payment_types = "'".$cumulative_payment_types."'";
Thanks,
Rado
|
 |
 |
|