Forum Moderators: open
Im making a php application that creates and invoice txt file from data stored in a mysql database.
In the invloice I need to list out each date/time that work was done and what was done on that date/time.
All of the text for the invoice is stored in a single variable called $stringdata. In this variable I want to include another variable called $billing info. $billing_info will look something like this when put into the text file
2007-10-15 1.2 hrs worked on project
2007-10-16 3.5 hrs worked on data1
2007-10-18 2.7 hrs worked on data2
ok, so my php looks something like this
$result = mysql_query("SELECT * FROM `log_time` WHERE `p_id` = 1");
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$p_id = $row['p_id'];
$hr = $row['hr'];
$mn = $row['mn'];
$yyyy = $row['yyyy'];
$mm = $row['mm'];
$dd = $row['dd'];
$desc = $row['desc'];
$b_id = $row['b_id'];
$billing_info = $yyyy.$mm.$dd."\t".$hr.".".$mn."\t".$desc;
}$stringdata = "
======================================================================
INVOICE# 20071018045820
======================================================================
My Company Name
1234 Ave A.
Houston TX, 78123
(512) 555-1357
======================================================================
Billed to:
$company_name
$contact_name
$address
$phone
======================================================================
Service of:
$p_name$billing_info
total due:
======================================================================
Please Make all Checks payable to:
My Biz
======================================================================
\n";$file = fopen("invoices/invoice.txt","w");
fwrite($file,$stringdata);
fclose($file);
The problem with this is that there is more than 1 record in the DB for this result. With my current code I am only able to list out 1 billing_info.
How can I accumlate all of them into one variable?
I have looked at an older post of mine [webmasterworld.com...] to try and figure this out but I am still not able to get it. Thanks for any help!
Thanks!
how would i do something like this
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$p_id = $row['p_id'];
$hr = $row['hr'];
$mn = $row['mn'];
$yyyy = $row['yyyy'];
$mm = $row['mm'];
$dd = $row['dd'];
$desc = $row['desc'];
$b_id = $row['b_id'];
$billing_info = $yyyy.$mm.$dd."\t".$hr.".".$mn."\t".$desc;
echo $billing_info;
}
this outputs several rows of biiling info such as
2007-10-15 1.2 hrs worked on project
2007-10-16 3.5 hrs worked on data1
2007-10-18 2.7 hrs worked on data2
how would I get
$billing_info_total = "2007-10-15 1.2 hrs worked on project<br />
2007-10-16 3.5 hrs worked on data1<br />
2007-10-18 2.7 hrs worked on data2";
I am trying again to get the output from that array into a single variable. Once in that variable I want to have that echoed into a txt file and email. make sense, please see this entire post for details. thank you!