charideem Posted December 22, 2011 Share Posted December 22, 2011 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! Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 22, 2011 Share Posted December 22, 2011 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"; } } Quote Link to comment Share on other sites More sharing options...
charideem Posted December 22, 2011 Author Share Posted December 22, 2011 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"; } } Quote Link to comment Share on other sites More sharing options...
charideem Posted December 22, 2011 Author Share Posted December 22, 2011 Now will this pass the LAST sale with Transaction_Type_ID 2 or all off them? Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 22, 2011 Share Posted December 22, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.