Question: How to return a row into table form and avoid fields that are null?

```
<?php
$o = mysqli_query("SELECT * FROM orders ORDER BY po_number DESC LIMIT 1");
echo 'The Following Order Information has been submited.';
echo '<table width="70%" border="5" align="center">';
while($row = mysqli_fetch_array($o)) {
    echo '<tr>';
    foreach($row as $field) {
    echo '<td>' . htmlspecialchars($field) . '</td>';
}
echo '</tr>';
    } 
echo '</table>';
?>

```

Answer: 
You could construct the `ObjectOutputStream` once and save the reference as a field. Also, you should `flush()`. Assuming you have a class `Snake` I would construct by passing in the `socket.getOutputStream()` like

```
private ObjectOutputStream oos;
public Snake(OutputStream os) {
  oos = new ObjectOutputStream(os);
}

public void sendSnake()
{
  try {
    oos.writeObject(snakeBody);
  } catch(IOException ioe) {
    ioe.printStackTrace();
  } finally {
    oos.flush();
  } 
}

```

And then you can call `sendSnake` with your `Snake` instance multiple times,

```
Snake s = new Snake(socket.getOutputStream());
s.sendSnake();
s.sendSnake();

```
You *must* use the same `ObjectOutputStream` for the life of the socket. More accurately, you must use `ObjectOutputStream` and `ObjectInputStream` in pairs: when you construct one you must construct the other at the peer. However this is basically impossible to co-ordinate so the single `ObjectInput/OutputStream` rule applies.

The `Snake` shouldn't send itself, and shouldn't be constructed or construct itself with a `Socket` [or `OutputStream` of any kind, contrary to other answers here]. The entity that is sending the `Snake` (or anything else) should own the socket and the output stream and should do the writing.