CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [RESOLVED] Appending string to variable

Print topic Send  topic

Author Message
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
View profile  Send private message
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;  
View profile  Send private message
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
View profile  Send private message
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"
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.