Jump to content

Please Help - PHP MYSQL Passing Entire Transaction Table to Affilate Network Ins


charideem

Recommended Posts

I just signed up for an affiliate network (commission junction) to help me drive traffic to my donation generation website for Charities.

My Software uses CAKE PHP on an Apache Server with MySql.

 

I had to put a pixel on the order confirmation page passing the Transaction ID and The Purchase Amount from the database.

The Transactions are located in the transaction table but the code that was written is passing EVERY Transaction in the database every time something is purchased.

 

The Columns for the transaction table are

 

ID  CREATED  MODIFIED USERID  CLASS TRANSACTION_TYPE_ID and AMOUNT

 

I have 32 types of Transactions in my Transaction_Type Table, the only transaction_types that are sales generated by the affiliate network are transaction_type 2.

 

The code I have now which isn't working correctly is.

 

<?php

// Make a MySQL Connection

mysql_connect("localhost", "frankgth", "andrew2011!") or die(mysql_error());

mysql_select_db("frankgth_groupon5") or die(mysql_error());

 

// Get all the data from the "example" table

$result = mysql_query("SELECT * FROM `transactions` ")

or die(mysql_error()); 

 

// keeps getting the next row until there are no more to get -

while($row = mysql_fetch_array( $result )) {

?>

 

<img src="https://www.emjcd.com/u?CID=1521593&OID=<?php echo $row['id'];?>&TYPE=349217&ITEM1=PURCHASE&AMT1=<?php echo $row['amount'];?>&QTY1=1&CURRENCY=USD&METHOD=IMG" height="1" width="20">

<?php

 

}

?>

 

 

How Do I only show this pixel if the action is Transaction_Type_ID is equal to number 2,with the Amount and Transaction ID.

 

Thanks in advaced. This site helps charity so i really want to get it working!

Link to comment
Share on other sites

I *assume* that the variable you need to check will be $row['Transaction_Type_ID'], modify it as needed.

 while($row = mysql_fetch_array( $result ))
{
    if($row['Transaction_Type_ID'] == '2')
    {
        echo "<img src='https://www.emjcd.com/u?CID=1521593&OID={$row['id']}&TYPE=349217&ITEM1=PURCHASE&AMT1={$row['amount']}&QTY1=1&CURRENCY=USD&METHOD=IMG' height='1' width='20'>\n";
    }
} 

Link to comment
Share on other sites

Would this be the complete code, I apologize as i am not a programmer at all.

 

<?php

// Make a MySQL Connection

mysql_connect("localhost", "frankgth", "andrew2011!") or die(mysql_error());

mysql_select_db("frankgth_groupon5") or die(mysql_error());

 

// Get all the data from the "example" table

$result = mysql_query("SELECT * FROM `transactions` ")

or die(mysql_error());

 

 

while($row = mysql_fetch_array( $result ))

{

    if($row['Transaction_Type_ID'] == '2')

    {

        echo "<img src='https://www.emjcd.com/u?CID=1521593&OID={$row['id']}&TYPE=349217&ITEM1=PURCHASE&AMT1={$row['amount']}&QTY1=1&CURRENCY=USD&METHOD=IMG' height='1' width='20'>\n";

    }

}

 

 

Link to comment
Share on other sites

Now will this pass the LAST sale with Transaction_Type_ID 2 or all off them?

I have no idea. All I can tell you that the condition will only create the image tag if $row['Transaction_Type_ID'] == '2'

 

The code I provided would replace the while loop you previously had.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.