create a recordset to return the ids, then create the array using code similar to:
<?php
$myArray = array();
do {
$myArray[] = "i".$row_RecordsetName['ID'];
} while ($row_RecordsetName = mysql_fetch_assoc($RecordsetName));
?>
you will need to replace "RecordsetName" with the name of the recordset and ID with the name of the ID column.
convert the array to a comma separated list using this:
<?php echo(implode(", ",$myArray)); ?>