OK, it sounds like you're dealing with two separate inquiries here...
first, you said this:
"this is my script but it shows all content of the table."
This sounds like you want to constrain your output to specific entries rather than showing all data. In that case, you need to employ the WHERE clause.
$query = "SELECT * FROM dbo.MS_UNIT WHERE some_column = 'some-value'";
The second part is that it sounds like you are looking for help formatting the output maybe? Not really sure... Sorry, but the image you referenced doesn't really explain exactly what you are wanting. Can you put your wishes into words?