表内的下拉列表

I want to make a dropdown list with table inside, the point is that I want both 'ID' and 'Name' field from a table in database to be showed up in the dropdown, so user can choose between 'ID' and 'Name' depending on which one is more familiar to them.

if I use:

<select>
    <option value="<?php echo $id; ?>"><?php echo $id." | ".$name; ?>
    </option>
    .....
</select>

the interface will not be neat, as the size of the IDs are different, for example like

ACDKH | Marsha
AIIIL | Anna

How can I make a table inside?

You can't, at least not without writing your own select box/functionality or using some plugin.

However, what you can do is use padding to format the output just like a table:

<option value="<?php echo $id; ?>">
    <?php echo str_pad($id, 8, '&nbsp;', STR_PAD_LEFT), " | ", $name; ?>
</option>

Note that this will put the non-breaking spaces (spaces that are always shown) at the left side of the id part (no need to put spaces at the right side of the name part). However, this will look nice only if you use monospaced fonts (where each character has the same width).