variables / reading files
| From: | Michael Hall | Date: | Sat, 23 Jun 2001 02:22:48 +0000 |
| Subject: | variables / reading files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-54953@lists.php.net to get a copy of this message | ||
I'm stuck on a piece of code for a shopping cart.
I'm on the final page where the buyer clicks BUY and several things
happen. I want to loop through the table that stores the session info and
extract details such as item, price, quantity, subtotal and assign all
this info to one variable:
$var = the output of a while($row = mysql_fetch_array($query)) statement
Why I'm trying to do this is I'd like to store all the purchase details in
one variable for inclusion in an email:
$message = $var; // (from above)
mail($address,$subject,$message);
I'd also like to put the info in that same variable into a table that
records actual sales data:
$details = $var;
insert into table ('details') values ('$details');
I know there must be a (probably very easy) way, but just can't crack it.
At the moment I'm writing the stuff to a temporary file then reading it
back again which isn't very elegant.
Also, is there any easy way to simply open and read a text file and assign
its contents to a variable? 'fpassthru','fread' and 'file' all seem to
have limitations in this regard:
fpassthru sends output to standard output and apparently won't store
output in a variable (unless I did something wrong)
fread needs a parameter for number of characters,
file adds <P> tags
Anyway, any suggestions greatly appreciated.
Michael hall