Hi,
Could you explain the difference between myRecordHandler($item) and myRecordHandler($product) ?
I see that in one example myRecordHandler($item) is used when records are to be printed to screen and in another example myRecordHandler($product) is used when data is to be dumped to MySQL.
The reason for my question is that I would like to take an example that works for me on screen from a URL source (with the correct MagicParser_parse string to use discovered at feedprocessor.com) but to dump the data into MySQL for later retrieval and display.
Many thanks,
Bangkok Bob
Hi,
Many thanks for your prompt response.
[quote]Hope this helps![/quote]
Yes, I have been a Member for: 9 hours 39 min and already learnt something new. I feel more confident now to try combining two examples you have into one to parse from URL and dump to MySQL.
Best regards,
Bangkok Bob
Hi Bob,
Funtionally, there is absolutely no difference between myRecordHandler($item) and myRecordHandler($product). Magic Parser calls your record handler function with one parameter - an associative array - but what you call both the function and the parameter is entirely up to you.
In my example code, I tend to choose a logical name for the array that represents the data it contains. The examples that parse an RSS feed I would use $item - as this is what each entry in an RSS feed is called. When working with affiliate product feeds however, $product is the logical choice as that is what you are working with.
The benefit extends into your own code by making it more readable, and hense maintainable; as the variable name can combine with the key name to make highly readable code. For example, if the product description field in your affiliate product feed was just called "Description"; you would use this in combination with the $product variable in the form $product["Description"] - helping you to create self-documenting code.
Hope this helps!