You are here:  » Need to have all the results in an array


Need to have all the results in an array

Submitted by neggs on Mon, 2006-02-13 10:44 in

Hiya,

Im wishing to use MagicParser to display sponsored links on ukfindit.com. UKFindit uses a purchased PHP script to obtain search results and display them. Therefore I can "tweaking" a PHP script to display some sponsored links from searchrevenueuk.com.

The script i am tweaking needs an array of the XML, therefore I have created a sample PHP page to try and do this.

<?php
  require("MagicParser.php");
  print "<ul>";
  function myRecordHandler($item)
  {
          global $xml;
          $xml[] = $record;
  }
 print "</ul>";
 $xml = array();
 $url = "http://www.searchrevenueuk.com/index.php?aff_id=44&xml=1&rows=10&str=money";
 MagicParser_parse($url,"myRecordHandler","xml|RESULTS/LISTINGS/LISTING/");
  foreach ($xml as $key => $value) {
  print $value["LISTING-TITLE"];
  print $value["DESCR"];
  print $value["LISTING-CLICK_URL"];
  print $value["LISTING-URL"];
  print $value["LISTING-BID"];
}
?>

I am quiet new to PHP, so may have made a n00b error or two!

Any help would be great!

Many thanks,

Paul (userid=neggs).

Submitted by support on Mon, 2006-02-13 16:05

Hi Paul;

What you have there should work OK; it's pretty much exactly what I suggested to another user in this thread.

Any probs just let me know...

David.

Submitted by support on Mon, 2006-02-13 16:34

Sorry - just looked at your code in more detail and noticed that you are not using the correct variable name when you try to add the current record to your global array...

You are coming into myRecordHandler with the record in $item, but you are trying to add $record to the global array; so you need to change the code within myRecordHandler as follows:

$xml[] = $item;

Hope this helps!

Submitted by neggs on Mon, 2006-02-13 17:05

Thanks David!

A second pair of eyes always helps :-)

I now have ukfindit.com fully working with the sponsored links! Im a happy man!

Ive also been playing with Price Tapestry. I'll you know if I intergate it to the main site.

Thanks again for your help!