Database driven affiliate websites

Garden Database Template

The database driven affiliate website is coming along ... if I do say so myself.

I am back from spring break 2008. Before you start thinking fun in the sun and wild parties, guess again. The family went down to southern Utah and visiting a couple of state parks, Kodachrome and Escalante, to get a little warmth in the desert. We camped out in the tent trailer - the first couple of nights were chilly - in the teens, 15-20F. But the days were very pleasant, 60-70F, and sunny.

Like I said, THE SCRIPT is moving along. I banged out some code tonight to have it pull results from the database.

database template

Note, the PHP code above should look familiar. It is a slight modification of the query code I created previously. It takes a word and finds one item in the database that has the same word, and pulls out the information from the MySQL database: title, affiliate link, image link, price and description.

Creative Code

The second chunk of code is where I get a little creative.

random database items

I am randomly choosing 5 to 10 additional items out of the database. This is for a sidebar menu that leads to other products.

Keep in mind that this is first pass coding for this affiliate site. I'm just randomly requested information - not taking into account whether the item selected is even in stock.

I'm thinking it would be worthwhile to have some hard coded links in place - specifically to categories like "trees", "shrubs", "flowers" - that kind of thing.

Print Out The Results

Three things in a row.

database template results

This PHP code does three things.

  1. Opens the template and reads it in to the script
  2. Makes replacements - substitutes the tokens (as an example, %%TITLE%%) with database results
  3. Prints out the results

There it is - let me know what you think so far.


Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Sphinn
  • Mixx
  • StumbleUpon
  • MisterWong

9 Responses to “Garden Database Template

  • 1
    Bria
    April 2nd, 2008 07:43

    Dave,

    This is becoming a real valuable piece of coding. It has so many potential uses from a full website to an insert onto pages.

    I really like the example you gave at:

    This could be inserted onto pages with other content and is a great way to show lots of related items to sell. This should work for SEO and for happy visitor experience. Just what Google wants!

    I did notice you have a "bug in your code" as %%RANDOM%% is showing up at the bottom of the links on each product preview.

    You need to debug that "bug in your garden"!

  • 2
    Art Deco
    April 2nd, 2008 11:26

    Hello Dave,
    I've been watching this closely as I have a new site in a similar niche.

    The db site is shaping up nicely, but your video on the blog says it's no longer available.

    BTW - no programmer or marketer is allowed to have a life or go camping ...

  • 3
    admin
    April 2nd, 2008 17:48

    Brian,

    %%RANDOM% - nah, that's not a bug - just an unused template variable.

    Did you also notice the %%OTHER%% and %%KEYWORDS%% token?

    Dave

  • 4
    admin
    April 2nd, 2008 17:50

    Art Deco,

    I don't know - time off is good for the creativity.

    Not sure what you mean by the video - the ones I have on youtube are showing???

    Dave

  • 5
    Art Deco
    April 5th, 2008 08:01

    The videos are working again - probably because you are back - like taking the car to the mechanic. I mentioned your tutorial at the design and programming section of WF affilliate forum - not safe for work, children, or any one easily offended BTW - you might want to stop by and comment. Or not.

    http://www.wickedfire.com/design-development-programming/27202-database-driven-site.html#post280727

    Art Deco

  • 6
    Brian
    April 6th, 2008 10:55

    Dave I missed those other TOKENS.

    But I don't want to miss the opportunity to have your Garden site!

  • 7
    admin
    April 6th, 2008 18:20

    @Art Deco - thanks for the plug ...

    @Brian, Let me know if you are a ShareaSale member AND and affiliate for Nature's Hill. Thanks.

    Dave

  • 8
    Linkvana
    April 17th, 2008 09:10

    Some very handy examples here - really building up my php skills. Would never have dreamed of attempting things like this a few weeks ago. You make it look so easy :o)

  • 9
    Garden Advice, Garden Tips, Tools and accessories.
    April 28th, 2008 07:47

    Dave:

    Your templated system is really top-notch. Talk about site-building simplification!
    I couldn't believe how easy it is to create a mega garden site that hosts the most up to date inventory of garden supplies, garden tips, gardening articles and garden accessories with very little overhead.

    The use of stylesheets makes it so drop-dead simple to alter the template to create a very personalized look and feel. Data-driven sites are really the way to go!

    Cudos to you Dave!

    JimL
    http://www.garden-buffs.com

Leave a Reply