Help with PHP looping system
<p>Hey I have a set of results returned from the database, they are numbers which represent 1 - 18 which are the drivers_id, it could return any number of those dependant on how many drivers retired from a race. I am then matching them up to the users drivers and if they match then to -10 points from the users points. </p>

<p>If they do not match then to +5 points. If the query returns no set at all then i know that the users four drivers can be +5 points each, but if it returns 5 rows, then how can I loop through those and match them up? and if there is no match add +5 points to that drivers variable, but it has to be after all the result set has been compared as that driver might be a match to the next row in $row. Thanks a lot for any help provided!.</p>

<blockquote>
  <p>p.s each driver_id in the result set is unique, so once a comparison
  is true then that driver_id will not appear again.</p>
</blockquote>

<pre><code>$results = mysql_query("SELECT drivers_id FROM results_retired WHERE drivers_id IN ('$driver1', '$driver2', '$driver3', '$driver4') AND track_id = '$track'") or die ("Failed to update" . mysql_error());

$retireddrivers = mysql_fetch_array($results)

if(in_array($driver1, $retireddrivers)){
  $driveronepoints -= $driver_points_system["retired"];
}
else {
  $driveronepoints += $driver_points_system["completion"];
}
if(in_array($driver2, $retireddrivers)) {
  $drivertwopoints -= $driver_points_system["retired"];
}
else {
  $drivertwopoints += $driver_points_system["completion"];
}
if(in_array($driver3, $retireddrivers)) {
  $driverthreepoints -= $driver_points_system["retired"];
}
else {
  $driverthreepoints += $driver_points_system["completion"];
}
if(in_array($driver4, $retireddrivers)) {
  $driverfourpoints -= $driver_points_system["retired"];
}
else {
  $driverfourpoints += $driver_points_system["completion"];
}
</code></pre>

<p>I have made some changes now to the code, is the in_array function ok to use in this instance??</p>

<p>thanks</p>
