使用PHP和SQLExpress Server 2008的复选框

I have a local application which currently reads data from a local SQL Server, this works well with SELECT queries and outputting text in a table however I'm having difficulty outputting a checkbox status either checked or unchecked :(

See my code:

<?php
    while( $row2 = sqlsrv_fetch_array( $stmt2, SQLSRV_FETCH_ASSOC) ) {
        echo "<tr>";
        echo "<td>" . "<input class=form-control id=input-readonly type=text name=supcode value=" . $row2['column1'] . " readonly></td>";
        echo "<td><input type=checkbox" . 
        if ($row2['checkbox_column1'] ==1) 
            echo "checked='checked'>" . "</td>";
        echo "</tr>";
    }

    sqlsrv_free_stmt( $stmt2);
?>

The checkbox_column1 column is a BIT datatype

Any guidance would be greatly appreciated, thank you!

You aren't closing the input if the checkbox column is empty. Also the concatation as noted won't work with the if.

Try updating to:

 $checked = $row2['checkbox_column1'] == 1 ? " checked='checked'" : '';  
 echo "<td><input type='checkbox'$checked></td>"; 
 echo "</tr>";

Demo: http://3v4l.org/HOojQ

If column == 1 output will be:

<td><input type='checkbox' checked='checked'></td></tr>

else

<td><input type='checkbox'></td></tr>