Results 1 to 7 of 7
  1. #1
    Newbie
    Join Date
    January 18th, 2005
    Posts
    3
    Hello all,

    I've noticed that some datafeeds have the categories and subcategories grouped together in the same column, like a breadcrumb-
    (main > cat > subcat > subcat2) I'm not sure what to do with that. Do you all split the column and make new columns out of that in excell or access or is there a way to do that dynamically? I'm a php novice, but I guess I can use the explode function in php and split the string into an array, but not sure where to go from there. Should I go that way or would it be easier to separate the categories and subcategories into their own columms?

  2. #2
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    I split it out and use up to 6 levels of categories (which is the most I've seen in a merchant feed). When I process the datafile, I split it out into separate database fields. I use Perl to process the datafeeds, so I couldn't give you any PHP advice.

    Every merchant handles categories just a little different. Some are cat>subcat. Some are cat.subcat. Some are cat-subcat. Some are cat::subcat. I bet I've seen 20-30 different ways of doing it.

    Michael Coley
    Amazing-Bargains.com

  3. #3
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    ÄúsTrálíĺ
    Posts
    1,372
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by tetsuo13:
    but I guess I can use the explode function in php and split the string into an array<HR></BLOCKQUOTE>
    This is exactly how I do it.

  4. #4
    Newbie
    Join Date
    January 18th, 2005
    Posts
    33
    I use explode also. BTW I limit to call SELECT query one call per page. I usually use JOIN to join the store table, category table, and detail product table together so I can use one call. Somehow, I think it's more convienent to store the whole bread crum and its links in detail product table so that I don't have to join category table...not sure if it's the right way. What do you think?

  5. #5
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    1,663
    By doing it in a single query within the database, my SQL statement searches the query and not the table.

    I use a series of query fields to parse the category field in an Access database query. The following defines a new query field consisting of everything to the left of the first "&gt;"

    <pre class="ip-ubbcode-code-pre">main_category: left([category],InStr(1,[category],"&gt;")-2) </pre>

    You can then define a query field consisting of everything to the right of the first "&gt;", then repeat in a progression until you've isolated every part of the database field.

    You haven't increased the size of the db by creating additional data fields and you don't have to manipulate the data everytime it's updated.

    I've done it within my ASP pages through a series of similar parsing routines but I think having the db do it once is safer and more efficient than having the page code do it.

    Wayne

  6. #6
    Newbie
    Join Date
    January 18th, 2005
    Posts
    3
    "I've done it within my ASP pages through a series of similar parsing routines but I think having the db do it once is safer and more efficient than having the page code do it."

    Meaning I should have these strings parsed into the database before hand rather than doing it dynamically through your page script?

  7. #7
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    1,663
    Yes. I prefer to have the database query parse it when the SQL statement calls it. Then the page script only has to call that specific query field as it would if I were calling a table field. It is a lot easier. The work has been done once and every page I write using that data doesn't have to address the issue.

    For me, having less code on my pages means less potential errors and it may make my scripts run faster since the script doesn't have to parse every record in the recordset. (Can't measure if this is true though.)

    Saying "having the db do it once" I meant that the category field is parsed once when the query is called, not that a query parses it into physically separate data fields. Nothing in your database fields actually changes.

    Wayne

  8. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Subcategories
    By bluewind in forum Cusimano.com Scripts
    Replies: 6
    Last Post: February 15th, 2005, 02:24 AM
  2. Feedback request: categories and subcategories
    By FourthWorld in forum WebMerge (Fourthworld.com)
    Replies: 4
    Last Post: January 26th, 2005, 10:21 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
  •