I think I know the issue when it comes to it the foreach is looping every port thats in the array so it picks up the online image but because its looping it will always do the last command which is offline so the offline image will always show even if server is online so my question is how can i make it so it shows the online servers only and as default it as offline also I have feeling the loop is bad too due to nature of it any help or advice would be great thanks.
foreach ($ports as $port) { $connection = @fsockopen($host, $port); if ($connection) { echo "ONLINE</br>"; $checkStatus = "1"; fclose($connection); } else { echo "OFFLINE"; $checkStatus = "0"; } } switch (true) { case stristr($checkStatus,'1'): $arrowStatus = "uparrow.gif"; break; case stristr($checkStatus,'0'): $arrowStatus = "downarrow.gif"; break; } if ($row["population"] < 150) { $imgString0 = "<img src='../../shared/wow-com/images/icons/serverstatus/bluerealm.gif' width='22' height='15'>"; $imgString1 = "<img src='../../shared/wow-com/images/icons/serverstatus/".$arrowStatus."' width='18' height='18'>"; $biildString = $imgString0 . $imgString1; } elseif ($row["population"] > 450) { $biildString = "<img src='../../shared/wow-com/images/icons/serverstatus/".$arrowStatus."' width='18' height='18'>"; } elseif ($row["population"] > 1000) { $imgString0 = "<img src='../../shared/wow-com/images/icons/serverstatus/alert.gif' width='22' height='15'>"; $imgString1 = "<img src='../../shared/wow-com/images/icons/serverstatus/".$arrowStatus."' width='18' height='18'>"; $biildString = $imgString0 . $imgString1; }