943,931 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3845
  • PHP RSS
Nov 8th, 2004
0

Double parsing variables?

Expand Post »
Hi guys, I'm Alex. I'm a complete n00b to the world of PHP and am glad that y'all have support available here.

Anyway, I'm unofficially doing tech stuff for a magazine and I'm working on a code to order subscriptions. I'm having a problem with variables in a loop I'm using...

So I have a bunch of forms that are being generated from a loop, based on a number ($num) that a customer chooses (we're talking about shipping addresses). This form, with however many generated shipping addresses, is then sent through a payment processing script and upon verification (ideally), the script will send out $num of emails to our distributer containing the shipping information for each subscription.

I wrote the loop so the forms that it generates are called "Firstname1" and "Firstname2" for example.

My problem is, in writing the loop to be run post-positive-verification, can I have the PHP parse its own variables?

Something like this:

PHP Syntax (Toggle Plain Text)
  1. case "1":
  2. for($i = 0; $i < $num; $i++) {
  3. mail ("Alex@worthwhilemag.com","Worthwhile Subscription Purchase",
  4. "A Worthwhile Subscription has been ordered for:
  5. \n$firstname$i $lastname$i\n$address$i\n$city$i, $state$i $zip$i");
  6. }
The double variables are what I feel is throwing me off. Anyone know if this is possible or I'm missing something?

I don't think I articulated this too well, btw...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alexruimy is offline Offline
1 posts
since Nov 2004
Nov 8th, 2004
0

Re: Double parsing variables?

hello alexruimy,

Try to use array

fpepito

try this example: http://www.fpepito.org/php/test3.php

[PHP]
<?

$customers = array(
array("Firstname", "lastname", "address", "city", "state", "zip", "e-mail@hotmail.com", "url"),
array("Francis", "Goncalves", "my adress", "Paris", "Ile-de-France", "75001", "test@hotmail.com", "http://ascejudo.mine.nu"),
array("Francisco", "Goncalves Andrade", "my address", "Lisbon", "Estremedura", "60000", "test@hotmail.com", "http://www.fpepito.org/")
);

#########

function read_customer($customers) {

#read each Customer on the list of Customers
while (list ($key, $customer) = each ($customers)) {
echo "send e-mail to $customer[6]<BR>\n";
echo "A Worthwhile Subscription has been ordered for: \n".$customer[0]." ".$customer[1]."\n".$customer[2]."\n".$customer[3].", ".$customer[4];
echo "<HR>\n";
}
}

read_customer($customers);
?>
[/PHP]
Reputation Points: 10
Solved Threads: 1
Newbie Poster
fpepito is offline Offline
14 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Cookies!!! , The Cheaters!!!
Next Thread in PHP Forum Timeline: PHP file handling





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC