Masspay and MySql

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-04-27T00:05:51Z Indexed on 2010/04/27 12:23 UTC
Read the original article Hit count: 329

Filed under:
|
|
|

Hi,

I am testing Paypal's masspay using their 'MassPay NVP example' and I having difficulty trying to amend the code so inputs data from my MySql database.

Basically I have user table in MySql which contains email address, status of payment (paid,unpaid) and balance.

CREATE TABLE `users` (
  `user_id` int(10) unsigned NOT NULL auto_increment,
  `email` varchar(100) collate latin1_general_ci NOT NULL,
  `status` enum('unpaid','paid') collate latin1_general_ci NOT NULL default 'unpaid',
  `balance` int(10) NOT NULL default '0',
  PRIMARY KEY  (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

Data :

1   [email protected]   paid    100
2   [email protected]   unpaid  11
3   [email protected]   unpaid  20
4   [email protected]   unpaid  1
5   [email protected]   unpaid  20
6   [email protected]   unpaid  15

I then have created a query which selects users with an unpaid balance of $10 and above :

  $conn = db_connect();
  $query=$conn->query("SELECT * from users WHERE 
                       balance >='10'
                       AND status = ('unpaid')"); 

What I would like to is for each record returned from the query for it to populate the code below:

Now the code which I believe I need to amend is as follows:

    for($i = 0; $i < 3; $i++) {
    $receiverData = array(  'receiverEmail' => "[email protected]",
                            'amount' => "example_amount",);
    $receiversArray[$i] = $receiverData;
}

However I just can't get it to work, I have tried using mysqli_fetch_array and then replaced "[email protected]" with $row['email'] and "example_amount" with row['balance'] in various methods of coding but it doesn't work. Also I need it to loop to however many rows that were retrieved from the query as <3 in the for loop above.

So the end result I am looking for is for the $nvpStr string to pass with something like this:

$nvpStr = "&EMAILSUBJECT=test&RECEIVERTYPE=EmailAddress&CURRENCYCODE=USD&[email protected]&L_Amt=11&[email protected]&L_Amt=11&[email protected]&L_Amt=20&[email protected]&L_Amt=20&[email protected]&L_Amt=15";

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql