SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pull Specific Data and Insert in MySQL

    Hello,

    I have a database that holds data for magazines. However, there is one merchant feed that holds a lot of needed information in one field. Is there any way to take something like this:

    magazine_title|magazine_description|New Renewal 1 Year 12 Issues For $9.95 2 Years 24 issues (+9.00) $18.95 3 Years 36 Issues (+18.00) $27.95|blahblah|blahblah


    can be turned into:

    magazine_title|magazine_description|12|9.95|blahblah|blahblah
    magazine_title|magazine_description|24|18.95|blahblah|blahblah
    magazine_title|magazine_description|36|27.95|blahblah|blahblah


    There needs to be one complete entry for each subscription length due to the way that my database is set up and how queries are run.


    Also, not all titles have 3 different subscription lengths, some have 1, some have 2.

    Thanks for any suggestions.

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, explode that string on the pipes. First element is title, second element is description. Explode the third element on spaces. iterate through the array and look for the word "issues" the element before will contain the number of months. Use this as a key for an output array and then keep iterating through the array looking for the first dollar sign in an element, this will be your price. Store that as the value for the key you just captured. By the end of the array you will have your information.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking of doing something like that but I just am not really sure where to start.

    Actually, there may be an easier way. The feed is an xml document. When I parse it (since I am not very good at it), that sections goes into the variable all as one. The section of the XML that holds the subscription data reads like this:

    <OptionLists>

    <OptionList name="Type">
    <OptionValue>New</OptionValue>
    <OptionValue>Renewal</OptionValue>
    </OptionList>

    <OptionList name="Subscription">
    <OptionValue>1 Year 11 Issues For $34.95</OptionValue>
    <OptionValue>2 Years 22 Issues (+20.05) For $52.00</OptionValue>
    </OptionList>
    </OptionLists>


    I can't find a way to pull just the information that I need from this. Any ideas?


Bookmarks

Posting Permissions

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