You are here:  » Affiliate Data to MySQL

Support Forum



Affiliate Data to MySQL

Submitted by Bangkok Bob on Sun, 2005-12-11 18:22 in

Hi,

I have used the code below to display product details but I am having some trouble combining this with the affiliate example from the manual in order to save data to MySQL.

Should the data be saved to a local file before import into MySQL?

Later,

Bangkok Bob

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($item)
  {
    print 
"<h2><a href='".$item["PRODUCTPAGEURL"]."402'>".$item["PRODUCTITEMDETAIL/ITEMTITLE"]."</a></h2>";
    print 
"<p>".$item["PRODUCTITEMDETAIL/PRODUCTTEXT"]."</p>";
    print 
"<p>".$item["PRODUCTITEMDETAIL/DURATION"]." ".$item["PRODUCTITEMDETAIL/PRICEDESCIPTION"]."</p>";
    print 
"<p><img src='".$item["PRODUCTITEMDETAIL/URLLIST/URL/URLLINK"]."' alt='".$item["PRODUCTITEMDETAIL/URLLIST/URL/IMAGEDESCRIPTION"]."' /></p>";
  }
  print 
"<h1>Bangkok Tours</h1>";
  
$url "http://www.affiliate.viator.com/xml/affiliateXMLData.jsp?IATA=BKK&Currency=USD";    
  
MagicParser_parse($url,"myRecordHandler","xml|VIATORAFFILIATEXMLDATA/IATA/PRODUCTITEM/");
?>

Submitted by support on Sun, 2005-12-11 18:29

Hi Bob,

There's no need to create a temporary file; you can go straight into a database from the feed. You need to create a database, and then use PHP's database functions to load each product entry into the database within your record handler function.

Do you have any experience at all with writing PHP code to interact with a MySQL database? The first thing you need to do is create a table to hold the product data. One way to do this is through a web based control panel such as phpMyAdmin - are you familiar with this product - it may be installed on your server.

Initially, you need to be in possession of are a username, password for mySQL on your server. Do you have these? Don't post them to this forum; just as long as you know what they are then I can help you further with some example code...

Cheers,
David.

Submitted by Bangkok Bob on Mon, 2005-12-12 06:43

Hi David,

Thanks for your note.

I am quite happy using PHPMyAdmin to work with MySQL but I have never written PHP code in my life! Cut and paste is all I aspire to. I have now set up a new database on a server for testing the MagicParser functionality.

I would certainly welcome some sample code to get started.

Later,

Bangkok Bob

Submitted by support on Wed, 2005-12-14 15:44

Hi Bob,

Sorry for the delay but i've now got time to put together a tutorials sections of this site. The first one i'll create will be setting up a MySQL database and loading product data from an affiliate datafeed. I'll aim to get that online by the end of this week.

Submitted by Bangkok Bob on Wed, 2005-12-14 23:37

Hi David,

That's magic. I'll watch out for your new tutorials section coming soon.

Later,

Bangkok Bob

Submitted by sgpratley on Wed, 2006-05-17 13:43

Where can I find a tutorial like this?
I want to create something a bit like your pricetapestry script, but for other products like mobile phones, travel, broadband where the attributes are different. What I need is:

1) Backend to Import XML or CSV feeds into a database ( I can create the database no problem)

2) Simple search & results page to query the database through drop down menus and return responses in rows.

Any idea where I can find something like that?

Submitted by support on Wed, 2006-05-17 14:42

Hi There,

The requirement to load affiliate datafeeds into a database is what led to the Price Tapestry script being developed in the first place; so in effect it became the tutorial.

One of the best ways to aproach this would be to study the Price Tapestry code and build upon it to create your customised back end (be extending the admin section), and a new front end (from scratch??) by using the Price Tapestry code as an example.

Taking the mobile phone example; if the feeds are going to be significantly different in format, but containing the same information (e.g. "free minutes"), then you will really want to develop an admin section that works pretty much in the same way as Price Tapestry's admin section - in that you can register feeds and associate each attribute with a particular field.

For example, if you look at each section of the code where price is registered and imported, you could copy each section to import a new field. Hope this helps...

Cheers,
David.