| | |
Double parsing variables?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2004
Posts: 1
Reputation:
Solved Threads: 0
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:
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...

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)
case "1": for($i = 0; $i < $num; $i++) { mail ("Alex@worthwhilemag.com","Worthwhile Subscription Purchase", "A Worthwhile Subscription has been ordered for: \n$firstname$i $lastname$i\n$address$i\n$city$i, $state$i $zip$i"); }
I don't think I articulated this too well, btw...
•
•
Join Date: Oct 2004
Posts: 14
Reputation:
Solved Threads: 1
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]
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]
![]() |
Similar Threads
- One method for stack of either Integer or Double parameters (Java)
- Java equivalant to C's getchar() (Java)
- Combining two programs (Java)
- variable burger might not have been initialized (Java)
- Why won't this compile (C++)
- How to code a friend template function? (C++)
- Need help with small beginner program, please. (C)
- Uber-N00B question (C++)
Other Threads in the PHP Forum
- Previous Thread: Cookies!!! , The Cheaters!!!
- Next Thread: PHP file handling
Views: 2660 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download duplicates dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php phpvotingscript problem query radio random recursion regex remote script search select server session sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





