Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In switching from authorize.net's SIM method over to AIM method of handling credit card transactions the way a LINE-ITEM is sent to the processor is different. In the (SIM) version, I could send line items by looping through the results and echoing the hidden INPUT field and its values with appropriate separators like this:

$qw = mysqli_query($con,"SELECT * FROM XCart WHERE Buyer_ID='xyz' LIMIT 30");
$ctr=0;
while($list = mysqli_fetch_array($qw))
{
    ++$ctr; 
echo "<input type='hidden' name=\"x_line_item\" value=\"".$list['Item_Number']."<|>".substr($list['Item_Title'], 0, 30)."<|><|>".$list['Item_Qty']."<|>".$list['Item_Price']."<|>Y\">\n";
}

But now, under the AIM method, the line items are assigned to an ARRAY, I am still in the infancy stages of PHP, but when I try to place a WHILE LOOP inside of the array similar to the above method, it gives me errors:

$line_items = array( WHILE LOOP INSIDE HERE);

The output of the AIM method should output as shown below, but I'm not sure how to loop through the results in a manner that gives me this output below. I'm missing something and/or doing it wrong, but any help would be appreciated.

$line_items = array(
    "item1<|>golf balls<|><|>2<|>18.95<|>Y",
    "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y",
    "item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y"
);
share|improve this question

1 Answer 1

$qw = mysqli_query($con,"SELECT * FROM XCart WHERE Buyer_ID='xyz' LIMIT 30");
$ctr=0;
$line_items = array();
while($list = mysqli_fetch_array($qw))
{
$line_items[] = $list['Item_Number']."<|>".substr($list['Item_Title']."<|>".$list['Item_Qty']."<|>".$list['Item_Price']."<|>";
}

something like this?

Be carefully, honestly you shouldn't be messing with payment system if you don't know anythign about PHP.....to learn more learn more about php arrays @ http://php.net/array

share|improve this answer
    
Wasn't able to get the output to be accepted by the payment API using what you provided - but thank you anyway. In response to your comment about the payment system: I'm new/learning, not completely knowledgless, having said that - it was integrated and working fine until they forced members to use a different API than was already in use. –  DMSJax Aug 28 '13 at 19:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.