Please have a look on this code. How can I implement this?

Lately i was done like this -
<script type="text/javascript">
function CheckPowerAll() {
    if (document.getElementById("PO_ALL").checked == true) {
        document.getElementById("PO_PowerSteering").checked = true;
        document.getElementById("PO_PowerMirrors").checked = true;
    } else {
        document.getElementById("PO_PowerSteering").checked = false;
        document.getElementById("PO_PowerMirrors").checked = false;
    }
}
</script>
<tr>
  <td><input name="PO_ALL" type="checkbox" id="PO_ALL" value="checkbox" onclick="CheckPowerAll()" />
Select all <span class="bold">Power Options</span> </td>
   </tr>
 <tr>
<td><table width="85%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td class="box2">
   <input name="PO_PowerSteering" type="checkbox" id="PO_PowerSteering" value="Power Steering" />
Power Steering<br />
   <input name="PO_PowerMirrors" type="checkbox" id="PO_PowerMirrors" value="Power Mirrors" />
Power Mirrors <br /></td>
  </tr>
</table></td>
  </tr>
<tr>
But now I need to populate the value from DB.
<input name="PO_ALL" type="checkbox" id="PO_ALL" value="checkbox" onclick="CheckPowerAll()" />
Select all <span class="bold">Power Options</span> </td>
   </tr>
 <tr>
<td><table width="85%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td class="box2">
<?php 
$query = mysql_query("SELECT * FROM vehicle_poweroptions"); 
    while ( $results[] = mysql_fetch_object ($query));
      array_pop ( $results );
        foreach ( $results as $option ) : ?>
<input name="PO_PowerWindows" type="checkbox" id="PO_PowerWindows" value="<?php echo  $option->id; ?>" />
<?php echo  $option->type; ?><br />
<?php endforeach; ?> 
How can I implement this?
 
     
     
    