Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 06-09-2006, 09:43 PM   #1
Baseband Member
 
Join Date: Jan 2006
Posts: 23
Default dependant incremental php variables

Hello! I'm trying to code up a handler for PayPal's IPN (Instant Payment Notification) feature. Since I'm going to be recieving information from a shopping cart and therefore multiple items, I need to make sure that I have a specific number of variables ready to accept the variables from PayPal. For example, if there are 4 different items from the shopping cart I need a variable to accept each:

Code:
$num_cart_items =$_POST['num_cart_items']
So if num_cart_items equals 4 then I need:

Code:
$item_name1 = $_POST['item_name1'];
$item_name2 = $_POST['item_name2'];
$item_name3 = $_POST['item_name3'];
$item_name4 = $_POST['item_name4'];
How do I make this so it will add as many number specifc variables needed depending on the number of items in the shopping cart?

Thanks!
__________________

blondegeek is offline   Reply With Quote
Old 06-10-2006, 09:05 AM   #2
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: dependant incremental php variables

use another variable to keep track of the amount iof items in the cart, and then pull the variables from the car into an array

<?php
$total = $_POST['totalitems'];

for ($x=1;$<=total;$x++)
{
$items[$x] = $_POST['item_name' . $x];
}
?>
__________________

__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 06-10-2006, 11:11 AM   #3
Baseband Member
 
Join Date: Jan 2006
Posts: 23
Default Re: dependant incremental php variables

thanks! that was just was i was looking for.
blondegeek is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 09:50 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0