You are here:  » If return no results


If return no results

Submitted by rubenxela on Mon, 2010-03-29 12:13 in

Hello David,
I'm trying to do something but I'm still unsuccessful after trying many things !

I've a simple function like

   function myRecordHandler($record)
  {
if ($_GET['ref']<>$record["CBIEN"]) return;
print "".$record["BIENDESC/LTITRE"]."";
// Some functions come here, but no problem for this side
  return TRUE;
 MagicParser_parse("".$feedprincipal."","myRecordHandler","xml|BACKSLASH/BIEN/");
 

So for this function there is no problem. It search an item in a large feed and returns informations.
My problem is (simple I think !!) that I need to return a message if there is no item relative to the search in the feed. Something like "else if" but I don't find the way to use this kind of function

Submitted by support on Mon, 2010-03-29 12:24

Hi,

The easiest way is to use a global variable which you set to TRUE within myRecordHandler so that the rest of your script knows that you have got results. Then if it is FALSE after the parse, you can display your message. Try something like this:

  $results = FALSE;
  function myRecordHandler($record)
  {
    global $results;
    if ($_GET['ref']<>$record["CBIEN"]) return;
    print "".$record["BIENDESC/LTITRE"]."";
    // Some functions come here, but no problem for this side
    $results = TRUE;
    return TRUE;
  }
  MagicParser_parse("".$feedprincipal."","myRecordHandler","xml|BACKSLASH/BIEN/");
  if (!$results)
  {
    print "Sorry, there were no results";
  }

Hope this helps!
Cheers,
David.

Submitted by rubenxela on Mon, 2010-03-29 12:28

That's it !! Thank you very much David.