title: How to use if...else statement inside a foreach loop?
body: <p>Ok im using this <code>foreach</code> loop to parse <code>xml</code> to add result data into my database I need to set the <code>$win</code> value but it always return 3 when it shouldnt b..</p>
  
  <pre><code>$myinfo = simplexml_load_file('http://mysite/results.xml'); 
  
  foreach ($myinfo-&gt;Event as $info): 
  
  $cid=$info['EventID']; 
  $a=$info-&gt;Match['AScoreNT'];
  $b=$info-&gt;Match['BScoreNT'];
  
  if($a &gt; $b){ 
     $win =1;
  } elseif($a &lt; $b){ 
     $win =2;
  } else{ 
     $win =3;
  }
  
  $sql = "
          INSERT IGNORE INTO `engine4_event_wins`
  SET `win_result` = $win,
  `comp_id` = $cid;
  
      ";
  
  
      mysql_query($sql);
  
  endforeach; 
  
  
  &lt;MyFeed&gt;
  &lt;Event Sport="AFL" Description="AFL - Finals - Week 1" EventID="651239"    FinalDate="2012-09-07T00:00:00"&gt;
  &lt;Match TeamA="Hawthorn" TeamB="Collingwood" AScoreNT="135" BScoreNT="97"/&gt;
  &lt;/Event&gt;
  &lt;Event Sport="AFL" Description="AFL - Finals - Week 1" EventID="651240"  FinalDate="2012-09-08T00:00:00"&gt;
  &lt;Match TeamA="Adelaide Crows" TeamB="Sydney Swans" AScoreNT="42" BScoreNT="71"/&gt;
  &lt;/Event&gt;
  
  &lt;/MyFeed&gt;
  </code></pre>