You are here:  » if record = X process if not ignore


if record = X process if not ignore

Submitted by cfrazeedbsi on Sat, 2010-02-27 06:45 in

With all your help and your help to others in this forum I have made tremendous head way on my script. Can you give us an example of ignoring the complete recourd between an xml tag (in my case items) if a recourd in the tag equals specific wording

This is how I would do it, but it does not work. The script does exactly what I want it to until I add the lines that are commented out below.

// $select-text = "constant"
function myRecordHandler($record)
{
// if ($record["MFGNAME"] = $select-text)
// {
    $search = array(Bunch of stuff);
    $replace = array(with this Bunch of stuff);
    $record["MFGNAME"] = str_replace($search,$replace,$record["MFGNAME"]);
    $search = array(Bunch of stuff);
    $replace = array(with this Bunch of stuff);
    $record["RCSTUS"] = str_replace($search,$replace,$record["RCSTUS"]);
if ($record ["MAP"] <= 0)
{
Calculations
}
else
{
Calculations
}
    global $link;
    $sql = "SELECT sku FROM translate_GS_to_SS WHERE sku = '".mysql_escape_string($record["SKURCRD"])."'";
    if (mysql_num_rows(mysql_query($sql,$link)))
    {
      $sql = "UPDATE translate_GS_to_SS SET
       (my note insert a bunch of stuff)
                WHERE
                 something
                ";
    }
    else
    {
      $sql = "INSERT INTO translate_GS_to_SS SET
       (my note insert a bunch of stuff)
                ";
    }
    mysql_query($sql,$link);
// }
// else
// {
}
  MagicParser_parse($xml,"myRecordHandler","xml|items/vwGSProdsXML/");

Thanks again for all your assistance.

Submitted by support on Sat, 2010-02-27 08:36

Hi there,

There are just 2 small problems in your code; $select-text is not declared as global in myRecordHandler, and secondly your IF statement uses "=" (assignment) instead of "==" (comparison). Have a go with:

$select-text = "constant"
function myRecordHandler($record)
{
  global $select-text;
  if ($record["MFGNAME"] == $select-text)
  {

That should do the trick!
Cheers,
David.

Submitted by cfrazeedbsi on Sat, 2010-02-27 16:03

Perfect !!!!!!!!!!!

For any one following this thread, the answer worked with one slight modification, I added ; after "constant" to make the line read:
$select-text = "constant";

Have a great weekend

Craig