Query with array

Below is the code for this problem i have.

I am running a few queries to do a few things.

First query creates column headers.

Second query shows users available.

Third quest displays users information.

What I need to do is take the returned value $result_machines and based on what column they are in from $machine_array either put <input type=checkbox checked> or <input type=checkbox>.

Any help

echo '<table><tr>';
echo '<td>Name</td>';
//echo "<td>Alert</td>";

$query_column = "SELECT uid, machinename from machineinfo";
$result_column = mysql_query($query_column);

$i = 0;
$machine_array = array();
while ($i < mysql_num_rows($result_column)) {
    $uid = mysql_result($result_column, $i, "uid");
    $column = mysql_result($result_column, $i, "machinename");
    echo "<td class=vertical>$column</td>";
    array_push($machine_array,$uid);
    $i++;
}
echo "</tr>";

$query_row = "SELECT uid, name, alertnumber FROM wkusers";
$result_row = mysql_query($query_row);

$j = 0;
while ($j < mysql_num_rows($result_row)) {
    echo "<tr>";
    $uid = mysql_result($result_row, $j, "uid");
    $name = mysql_result($result_row, $j, "name");
    $alert = mysql_result($result_row, $j, "alertnumber");
    
    
    echo '<td nowrap>'.$name.'</td>';
    //echo "<td nowrap>$alert</td>
";
    
    $query_machines = "SELECT machine from usermachineassociation where user = $uid";
    $result_machines = mysql_query($query_machines);
    
/**
     * Help is needed here
     */

    foreach ($machine_array as $val) {
        if (in_array($row,$val) {
echo "<td></td>";
    }
    
    
    echo "</tr>
";
    $j++;
}
echo "</table>";
?>