You don't need a foreach() loop in this case because while() acts as a loop with the MySQL rows you selected. You're missing a closing curly bracket, by the way but that could just be a problem with copy and pasting.
Try this:
PHP Code:
$sql = mysql_query("SELECT id FROM servers WHERE active = '1'") or die(mysql_error());
while($ids = mysql_fetch_array($sql)) {
$get = mysql_query("SELECT * FROM servers WHERE id = '{$ids['id']}'") or die(mysql_error());
$serv = mysql_fetch_array($get);
// rest of process here using $serv['cell_ref'] as a reference.
}
Just a few notes...
I added
or die(mysql_error()) onto the end of your MySQL queries. This is good practice because it will let you know of any errors in your query immediately which can save a lot of time when coding in the future.
I don't know exactly what you're doing here or your table structure, but SQL queries in loops can be considered slow and should be avoided if there's another, more efficient way to do what you want to do.