How to pull product datafeeds using PHP and MYSQL and display into your Webpage
Affiliate Project recently received a comment on this post – Niche site launched using data feeds and decided to create this post to help any other affiliates with displaying product data feeds.
We initially struggled to get product data feeds working. We found it hard to find how to get this to work, so thought we would document this on our blog and this could also help other affiliates.
There was 3 basic steps to get the data feeds to be displayed on the page.
Before you do this, you will need to download your data feeds and then create a new database using phpmyadmin (often from cpanel tools). Create the field names as per your datafeed or merchants datafeed.
1st step:
Create a php page template. So in the php file you will specify template name, pull in the header and title, then when you login to wordpress and add a new page, you can specify this new page template (your_template_name).
EXAMPLE:
<?php
/*
Template Name: your_template_name
*/
?>
<?php get_header(); ?>
<div id="content">
<span class="breadcrumbs">Browse: <strong><a href="<?php echo get_option('home'); ?>/">Home</a> » Your Template Name</strong></span>
<h2 class="title"><?php the_title(); ?></h2>
<?php
2nd step:
Put the php code that has the mysql statements that query the database which holds the datafeed
EXAMPLE:
// Connect to Database
$con = mysql_connect("localhost","database_name","database_password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// Select the Database
mysql_select_db("database_name", $con);
// Select the data from table_name
$result = mysql_query("SELECT field_a, field_b, field_c, field_d, field_e FROM table_name WHERE field_f='category_name'");
3rd Step:
Display the data from the database in table format, then loop the products. After that close the connection and display the sidebar and the footer
EXAMPLE:
// Display the table
echo "<table border='0' cellspacing='16'>";
// Put results into table
$counter = 0;
while($row = mysql_fetch_array($result))
{
echo "<td WIDTH='112' align='left' valign='top'><a href=\"" .$row['field_c'] . "\">
<span class='producttable'><img width='140' src=\"" . $row['field_d'] . "\" border=1 alt=\"" . $row["field_d"] . "\" title=\"" . $row["field_b"] . "\"></span>
<br><span class='producttext'>$row[field_a]</span></br><br>$row[field_b]</br></span></a>";
echo "<br><span class='producttext'><strong>£$row[field_e]</strong></span></br>";
$counter++; # increment count every iteration
if ( $counter % 3 == 0 )
{
echo "<tr />";
}
}
echo "</td>";
echo "</table>";
// Disconnect from Database
mysql_close($con);
?>
</div>
<?php get_sidebar() ?>
<?php get_footer() ?>
You can style the output how you wish with css styling.
w3schools.com is a great resource for website coding such as html / php / mysql.
Hope this helps other affiliates.
Maternity Swimwear – back where we belong, #1
Checked Google this morning and Maternity Swimwear is back at number 1 for the non-exact global search term maternity swimwear. Phew. We are well chuffed as it was a bit of a shock to come in yesterday and find it had dropped from the face of the earth, or should I say Google earth.
So what happened. Ok I’ll admit it, it was me! Me and my fat fingers, or fat mouse clicks. Well not all me. I’ll explain. I was updating our database on Wednesday and instead of emptying our product table to re-import the changes I had made, I dropped the table. This was quickly rectified by myself and Gary and we quickly had the database back up and running, probably within 5-10 minutes. However due to a plugin that we installed, wp-cache, the site was cached and wouldn’t update even though we were running SQL queries so we knew the database was fine. This wp-cache meant the site wasn’t updated for a good while and during this time it appears Google crawled the site, received the cached SQL and PHP errors and added entries into our robots.txt file. This then meant Google thought the site was invalid and dropped it.
What did we do to rectify it. Well we searched for reasons why a site can be dropped. We had heard of this before, duplicate content, bad code can be some of the reasons so we did a quick check, no problems there. So we used Google webtools. We then found out the robots.txt had changed and a lot of Disallow entries had been added by Google. So we removed the invalid entries and increased the rate at which google crawls the site in the hope we get back up there. Then this morning we have checked and there we are, number 1 in Google again. We are chuffed as we have worked really hard to get this site to number 1 in the first place so it was a bit of a shock to not find it up there yesterday. However we have learnt from this. Onwards and upwards.
We have said this many times before but this is all a learning curve. In hindsight maybe it was good for us to experience this as it improves our skills in this business. We had to diagnose what had happened and put in place corrective steps to get it back. It only took our site down for 1 day. Not bad if you have many sites, but when you are starting and only have a few niches it can make you panic. Ok it can make me panic but then I am a worrier. Good job Gary is the calm collective one. I just run around screaming.
Niche site dropped from #1 position on Google overnight
Today we noticed that one of our niche sites had dropped from Google for the keyword search terms maternity swimwear. We have started to analyze the site to try and figure out what could have made this suddenly drop
A quick look at Google Webmaster Tools and we noticed our Robots.txt file had several disallows for most of the main pages, but not the home page. We are not sure why this happened. The only recent change that we are aware of was that we updated the product feeds and had accidentally dropped the table in phpmyadmin. We had quickly re-created the table to update the product feeds, but for about 3-4 hours our site was not showing the products. We think this was because of the wp-cache plugin which has been causing us lots of problems recently. We had disabled this ages ago but it still seems to be caching. We knew the code in our php file hadn’t changed and that the sql statement was working ok, so must have been the caching problem.
Our site has been in top 3 position for almost 1 month now, soon after the launch of the site, so we are really confused why this would suddenly disappear.
We have also posted a question on Google Webmasters Forum, but some comments we got were not very constructive. We know the site needs some improving and will make some changes over the next coming weeks to help with this, but why would our site just drop.
A site:maternityswimwear.org.uk shows our site is also still indexed, so it doesn’t appear to have been penalised. Google Search for www.maternityswimwear.org.uk is still there.
Our only conclusion is that Google bots had tried to crawl our site when there was no content effectively so because of this our site has dropped to page 9 instead of page 1, position 1.
We will wait a few days to see if Google bot puts our site back where it belongs, at the top
Has anyone else experienced this problem, or can provide us with some advice, we’d like to hear your comments.
Balancing home, family, work and the Affiliate Project
After Gary’s great post about how he spends his day I am going to do the same so you can get another perspective on how a part time affiliate spends their day. This is how most week days are spent at the moment. It is a busy day, fitting in a full time job, spending time with the family (which is my favourite part of the day) and putting in some quality hours for affiliate project work. Like Gary I have a young family and that is the most important thing for me.
06.00 – Alarm goes off and I try and see if I can get at least 2 snoozes in before getting up and getting ready for work and sneaking out of the house trying not to wake anyone else up.
06.20 – Pickup lunch made the night before, running kit and laptop and head for work.
06:45 – Arrive at work, grab a shower and get ready to start the working day in my full time job at 7am.
07:00 – Start work on full time job and work through to lunchtime taking the occasional break.
13:00 – Break for a lunchtime run and shower. Usually run between 4.5 and 6 miles. I like to keep fit as well and this does help the concentration levels so run most weekdays.
14:00 – Return from lunchtime run and continue work.
15:30 – Leave work and have 25 minute drive home.
16:00 – Walk in the door to be greeted by my wonderful family. Time to catch up on what they have been doing for the day and relax and spend time with them, have dinner and then think about bed time for the kids.
18:30 – My wife and I take it in turns to bath the kids, read them stories and put them to bed. One night it will be my turn to do my 2 boys (twins), the next it will be my turn to do my daughter.
19:30 – Finish bed time routine, now time to clear up the house and make lunches for the next day for myself and my daughter who is at school. I normally clear up while my wife makes lunches.
20:30 – Start-up Laptop and carry on with Affiliate projects. This normally involves checking emails, site design and content writing. Try not to get too distracted with the T.V. that will be on. Try to focus on good quality work rather than checking accounts and other blog posts too much.
22.30 – 23:00 – Shutdown for the night and try and have half hour to chill out. Normally try and read a book but usually only manage a few pages before falling asleep to get some well earned rest.
This is my routine for most weekdays, although there is room for the odd night out and I also spend some evenings away from the project with my wife, maybe having a takeaway or just chilling out. I actually really enjoy the affiliate work and with a long term goal to work towards don’t mind putting in the hours. I also try and have a couple of nights off a week.
Affiliate Project Groundhog day – how my day is structured
Affiliate Project has been going now since the end of January 2009. We update this blog with stats and updates on our progress, but came across another part time bloggers site and they asked the question – how do you spend your days as an Affiliate? Thanks Joe (howigotrich.net) for the idea
Myself and Paul (partner in crime, purely Internet Marketing) are constantly talking about how busy we are now we are doing Affiliate Marketing stuff.
So here is my answer, I’m sure Paul will post his in the next few days as he’s having a couple of days off to spend with his family.
5:45am alarm goes off, think shite where is my phone and then quickly hit the snooze button.
6:00am get out of bed, jump in shower to wake myself up, regret staying up late the night before and thinking I spent way too long on the laptop and feel bad for neglecting the misses most of the night.
6:10am chuck on clothes if ironed, otherwise head downstairs, iron clothes, make sandwiches for work, get gym gear ready, then rush to work for 7am
7:00am – meant to be at work as a Tech Support Engineer, suppose to be available for any live calls.
7:10am – whoops, arrived at work, check the Queue for any calls, if no calls, check e-mails and my widgets (buy.at and Affiliate Window) to see any earnings from the day/night before.
9:00am – meet up with Paul for a break aka morning meeting to discuss our daily Affiliate tasks, although we mostly end up talking about ‘when we can do this full time, we could just meet up on the golf course, then to the clubhouse every Monday. Pipe dreams I know, but its a nice thought
9:30am – back to desk to do boring support cases
12:00am – lunch time, most often head to the gym
1:00pm – back to my desk, hope there is no Customer’s chasing, if not to busy, try and do any updates to sites, put any new ideas into google docs, check google reader to keep updated with other affiliates blogs
3:30pm – leave work, either head home to play with 18month old daughter or pick her up from nursery then feed her, spend the next few hours with her and my wife
7:00pm – daughter goes down for the night, myself or my wife will cook dinner, eat dinner then tidy up
8:00pm – Sit in front of the TV, trying not to spend too much time away from my wife, although this is probably when I’m least responsive as I’m focused on Affiliate stuff and finding it difficult to work with TV distractions and tiredness from the busy day. I try and spend this time trying to finish off niche sites, trying to improve existing sites, whether it be SEO or how to make them convert better. But I must admit most of the time is done doing research, trying to think of what could be a big earner to help reach the ultimate goal and do this full time earning a full time wage. Also I must check out other affiliate sites to get ideas of how they do things as they are obviously doing ok.
11:00-12:00pm – eventually close the lid on the laptop, think more to do the next day
I’d be very intersted to hear how other part time or even full time Affiliates days are spent whilst doing Affiliate Marteting.
Relaunch of niche site after facing problems with potential domain Trademark Infringement
Recently we had received legal notice about one of our niche sites from the prominent company, stating that we needed to relinquish the use and rights to the web site domain because the domain name and the use of the domain keywords was similar to the prominent company.
We didn’t realise that we had done anything wrong as we had checked the trademark and it wasn’t registered as a trademark for the domain name we were using. However we decided it was best to de-register the domain name as we now understand the problem. Our domain name could have been seen to be confusing to the public into thinking the trademark holder is somehow affiliated with our web site.
So rather than forget about the niche site altogether and loose out on any earnings, we’ve decided to re-launch the site but this time using a domain name that doesn’t Infringe on any trademark. Our new site is called UK Vibration Plates or www.ukvibrationplates.co.uk. The previous site was using domain keywords Powerplates which had become quite a generic term when searching for vibration fitness machines.
The funny thing was that we weren’t selling any of the Power Plate products, possibly due to the price as most of our sales were coming from the lower priced models such as the Body Sculpture BM1500 for just over £130, and the Horizon Treo V109 and Horizon Treo V209 slightly more expensive but still a bargin and all very popular machines according to Amazon’s sales ranks.
We hope that this site will do better for us now we have a more commonly used keywords in our domain name, although the competition may be stronger. The challenge is on
Family Business website facing Google indexing problems
Recently I have developed a website for a family member and after finishing the design, the next stage was to get it indexed into Google. Well we had problems at the first hurdle as the site was taking ages to get indexed even after posting here about it, which usually helps for our other niche sites.
I noticed that the site was indexed when typing in site:domain_name.com but it was only showing the website domain name and no meta description.
After analyzing the site, I came up with the following problems which could explain why it was not showing properly, but this is still unclear as to what the exact cause was.
- Robots.txt file was set to Disallow /
- We set this up while designing the site as didn’t want the pages to be indexed with incorrect content or pages and then have to ask Google to remove certain urls etc.
- We had modified this to Allow / quite early on, but maybe it was taken some time for the google robots to pick up these changes. The robots test showed the correct information - We had some javascript on the main home page, this script was a basic expand and collapse text script so had hidden text but when clicked would display the text. This could have been seen by Google as spamming as we could be hiding keywords. But I’m sure loads of other sites use this and don’t have any indexing problems. Anyway this has been changed now to click through to another page, so no more javascript
- No 301 .htaccess redirect file set-up so that our non canonical domain http://domain was not being redirected to the http://www.domain… etc. This could have been seen as duplicate content across the domain. This has now been set-up.
Well a few days later and more of the pages are being indexed with the description. Still though the home page or root of the site isn’t showing the description and I’ve triple checked the code, its no different than some of the other pages codes.
For those interested the family site is Expand Internationally or http://www.expandinternationally.com
Any comments/suggestions welcomed
Affiliate Project dabbles in Dreamweaver to help family business
Recently Affiliate Project was approached by a family member asking for help with starting up a business adventure. They had seen and heard about our success with a few of our niche sites and how we have managed to get the sites listed in the top ranks on google in little time and sought our help to design, develop and SEO the site.
As we have only really had experience with using Wordpress to get our sites out there, it wasn’t straight forward to design the site as the requirements although basic weren’t really suited for Wordpress. Rather than hack a Wordpress theme to suit our needs, we decided to build the layout and style this from scratch using css and code with html with the help of Dreamweaver.
The site for any one interested to see our work is www.expandinternationally.com. Its basically a business website that is aimed towards companies that are looking to export services internationally. In this current market businesses are looking to cut costs and doing business overseas is one way business can save money. However its not that straight forward for companies and that is where Expand Internationally can help with over 100 years experience in doing business internationally.
Our challenge is going to be a little harder as we’re not trying to SEO a niche site. This is a business site and we need to try and understand the market and the target audience, but we love a challenge and this is what we’re in the Affiliate Marketing business for.
Hopefully the site will get up in the rankings so we can prove to the family that we are keen in doing Affiliate Marketing full time.







