Results 1 to 20 of 20
  1. #1
    Newbie
    Join Date
    January 18th, 2005
    Posts
    20
    Let's say I already have an automated process of downloading a datafeed and inserting the data into my database.

    Instead of using the database (or just the datafeed file) to create an actual .html or .php page for each product, is there a way to dynamically generate a page based on the data you have in your database ?

    For example, let's say my hompage lists 100 products, each product linking to a URL which is identified by the product name... ie:
    http://www.somepage.com/green-product.php
    http://www.somepage.com/123abc-blue-hat.php

    ... I could dynamically generate these URL's... however, how would I create the actual pages ?

    I'm assuming I would need to use mod_rewrite to parse query-string parameters, so I could pass the product name to a page with name-value pairs , and have the page rewriten to show as a path/filename ?

    Any ideas would be greatly appreciated !

  2. #2
    Intergalactic Trader IGshop's Avatar
    Join Date
    January 18th, 2005
    Posts
    87
    Ultraman,

    I'm just learning how to do this now. I went to the library and got "PHP and MySQL for Dummies". That'll get you started. Also, sitepoint.com has some stuff you can download about this also.

    Jim

  3. #3
    Newbie
    Join Date
    January 18th, 2005
    Posts
    20
    hey rofous !

    i'm not to shabby at PHP and MySQL, but I think I just need some insight on how to utilize "mod_rewrite" properly.

    for example, if i have a database full of products, how do i go about dynamically creating a page like below that has the filename as a product:
    http://www.somesite.com/green-blue-hat.php

    it has to do with how you use "mod_rewrite", but i'm just a little confused on the process.

  4. #4
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    Actually, mod_rewrite is only part of the process.

    There are lots of ways to do what you want, but here's one:

    1) Write a program to generate a page, with the parameters passed in. For instance http://www.somesite.com/pagegenfromd...green-blue-hat

    2) Use mod_rewrite to rewrite requests. For instance, something like http://www.somesite.com/detail/desc.html should be internally converted to http://www.somesite.com/pagegenfromd...prod_desc=desc

    Another thing that helps is to generate the "description id" when you load the database. Make sure to trim out all characters that might be confusing in a URL. You might want to append the sku if the description is not unique.

    Michael Coley
    Amazing-Bargains.com

  5. #5
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,015
    Why not do this?

    http://www.mysite.com/catalog.php/product_name

    You can extract the extra path info by looking at the variable $_SERVER["PATH_INFO"].

    Makes life easier than messing with mod_rewrite.

    --
    "The greatest good you can do for another is not just to share your riches, but to reveal to him his own." – Benjamin Disraeli
    --
    Ford Fox-body Owners Club -- http://www.ford-fox.org

  6. #6
    Member
    Join Date
    January 18th, 2005
    Posts
    148
    Hi,

    For those of you using PHP, you might also want to take a look at Smarty:

    http://smarty.php.net

    It is a template engine for php. It is a definite help in controlling design elements, rather than having them embedded in the PHP code.

    Maria

  7. #7
    Newbie
    Join Date
    January 18th, 2005
    Posts
    20
    Hey MichaelColey !

    This solution is what I was working on, but then got stuck when it came to product names which contain trademark symbols, double quotes... and other special characters.
    I'm able to translate these characters into their entity/decimal equiv's, but, my URL's end up looking *horrible*.

    When you were speaking of "generate the 'description id'", what were you referring to exactly ?

    I'm using a DB to store all the product data, and not going with a static html file approach, and am having an extremely difficult time trying to wrap my head around keeping the URL's looking good.

    Any insight would be greatly appreciated !

  8. #8
    Member
    Join Date
    January 18th, 2005
    Posts
    145
    I'm trying to learn PHP. Anyone one how to rewrite:

    http://www.mydomainname.com/index.php?m=brandname

    to

    http://www.mydomainname.com/brandname.php

    I've been reading into mod rewrite but I can't figure it out.

  9. #9
    ABW Ambassador sjangro's Avatar
    Join Date
    January 18th, 2005
    Location
    Boston
    Posts
    1,529
    Actually, it's a little easier to think of it as rewriting

    http://www.mydomainname.com/brandname.php

    to

    http://www.mydomainname.com/index.php?m=brandname

    Since that's actually what mod_rewrite is doing.

    Assuming you have mod_rewrite available on your Apache server, your .htaccess should contain this line:

    RewriteEngine On
    RewriteRule ^(.*)\.html$ index.php?m=$1

    This assumes the convention that the entire filename is going to be that single parameter value. That means that every file ending in .html will get rewritten. For example, if you have a static page called about.html, that'll get rewritten as well.

    --scott

  10. #10
    ABW Ambassador cditty's Avatar
    Join Date
    January 18th, 2005
    Location
    Memphis TN
    Posts
    1,434
    Cool Scott. How would you do it for something like this?

    http://www.mydomainname.com/index.ph...s=blah&t=blah2

    Basically to allow for a dynamic sized url.

    Chris

    ----------------------------
    <FONT SIZE=1>ezDatafeed.com - Merchants - Give your affiliates your datafeed outside the networks, without cost to the affiliate. Check out ezDatafeed.com for more information.
    Scriptsforyoursite.com - Featuring datafeed import scripts for Backcountry Store, Coldwater Creek, Mondera.com and many more.....</font>

  11. #11
    Full Member
    Join Date
    January 18th, 2005
    Posts
    347
    Chris, have a look at this URL:
    http://www.webmaster-toolkit.com/mod...enerator.shtml
    Simple to use. I love it.

  12. #12
    Newbie
    Join Date
    January 18th, 2005
    Posts
    19
    Hello Guys,

    I am new to these forums...recently i started a deals site and soon i am planning to start a simple comparison pricing engine by utlizing all the available datafeeds...

    I need some suggestion from you guys..

    Here is my process as of now..

    -> Wrote a java program to download from ftp to local system
    -> Another Java Program reads the text file and loads in to mysql database at my local system.
    -> After that i'll generate a sql dump from mysql
    -> zip the dump and upload and unzip it..finally load it to the database..

    Major problem for me is how to update the database as some feeds are updated daily and some feeds are updated weekly..i wanna know what you guys doing when u get a updated feed.

    Thanks in Advance

  13. #13
    Member
    Join Date
    January 18th, 2005
    Posts
    145
    Thanks ScottJ! I'll try it out.

  14. #14
    Member
    Join Date
    January 18th, 2005
    Posts
    145
    NICE! That worked but I do have more than parameter. This is for one of cditty's scripts. I least I'm getting somewhere. How do you add more than one rule in the htaccess file? (if that's what I need to do) Thanks again!

  15. #15
    ABW Ambassador CrazyGuy's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,463
    Urging a little realistic caution ...

    Mod rewrite rules are very difficult to get completely right unless you have planned both the real and virtual structures of your site with it in mind.

    There are pitfalls and exceptions in almost any mod rewrite situation. For example, in Scott's example above, as he says - every .html page sought for will get rewritten as a .php page. Other common pitfalls include how to rewrite folders - mydomain.com/folder - without a filename, and with or without final slashes.

    I believe you can cascade rules and you can pass the output of one rule to another rule, but the fact they are all based on regular expressions has been the biggest stumbling block for me.


    --------------
    Are you Crazy?

  16. #16
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by ultraman:
    This solution is what I was working on, but then got stuck when it came to product names which contain trademark symbols, double quotes... and other special characters.
    I'm able to translate these characters into their entity/decimal equiv's, but, my URL's end up looking *horrible*.

    When you were speaking of "generate the 'description id'", what were you referring to exactly ?<HR></BLOCKQUOTE>What I was talking about was having two description fields in your database. One exactly as it should be displayed ("Red Widgets - Refurbished") and the other should be translated into a more generic format ("red-widgets-refurbished") that is friendly in a URL.

    Michael Coley
    Amazing-Bargains.com

  17. #17
    Member
    Join Date
    January 18th, 2005
    Posts
    73
    Hi Kellmk;

    Did you ever get this working with more than one parameter? I too am trying to get mod-rewrite to work with one of Cditty's scripts and am tearing my hair out.
    Anybody?

    Laertes

  18. #18
    Super Sh!t Stirrer SSanf's Avatar
    Join Date
    January 18th, 2005
    Posts
    9,944
    Now, I suspose I will have to learn how to do this, too! Cripes! I haven't even really figured out the other thingy, yet.

    I want my mommy!

    Mr.Merchant, if you do business in any way what-so-ever with parasites, your products will not be sold on my sites!!
    Affiliates, before you use CJ merchants, Read This! Comments are to be interpreted as opinion unless otherwise noted.

  19. #19
    Full Member jollygoodpirate's Avatar
    Join Date
    January 18th, 2005
    Location
    NC
    Posts
    227
    To pass several parameters you could create a url with each parameter looks like a subdirectory:

    /redwidgets/3/10/price/

    then you are looking at redwidtgets, page 3,10 items in each page, ordered by price. I think amazon does this on their site.You can find out in your script the calling URL and explode the URL into pieces.

    Or if you are more bold you can do it by exploding the name of the file:

    redwidgest-10-3-price.html

    then delete the .html, separate each piece and run your script with the passed parameters.

  20. #20
    ABW Ambassador CrazyGuy's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,463
    An inspiration I had to avoid the "cr*p, now all my html files are being re-written" scenario:

    Apply the rewrite rule to one set of file extensions (say .htm) and make your "real" pages (say) .html.

    That way you know anything referring to a .htm is a dummy reference that will be rewritten, and your real pages don't get affected.

    @jollygoodpirate - I'm working on variations of your second suggestion. One problem with the first idea is that it looks like your files are several directory layers deep, and I believe Google esp does not like that.

  21. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. comparison site without datafeeds
    By awaken in forum Newbie Affiliate FAQs & Helpful Articles
    Replies: 9
    Last Post: July 14th, 2007, 04:36 PM
  2. Displaying datafeeds on a site
    By bcorso in forum Marketing Resources & Power Tools
    Replies: 4
    Last Post: January 14th, 2007, 03:35 PM
  3. Datafeeds Site Id
    By bbb in forum Commission Junction - CJ
    Replies: 1
    Last Post: September 13th, 2003, 05:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •