Michael Hall pressed the little lettered thingies in this order...
>
> 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.
>
$result = mysql("DBName","QUERY");
while ($row = mysql_fetch_row($result)) {
$var = $row[0];
$message .= $var;
}
$details = $message
The period and equal sign cause $message to prepend itself to $var.
This is the same thing as writing:
$message = $message."$var";
In either case, $message is preserved and added to on each loop. That
being the case, if you are puting this into an e-mail message, you
probably want to add line breaks after each line:
$message .= $var."\n";
Check out string operators:
http://www.php.net/manual/en/language.operators.string.php
and assignement operators:
http://www.php.net/manual/en/language.operators.assignment.php
Good luck...
Christopher Ostmo
a.k.a. [EMAIL PROTECTED]
AppIdeas.com
Meeting cutting edge dynamic
web site needs
For a good time,
http://www.AppIdeas.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]