I wanted an "available options" type of field. This is a product (camp stove) that needs to be sized specifically for a given pot. When the customer checks out, he or she must choose a pot from a select list, but I also wanted the product page to have a "compatible pots" tab that would have all pots listed in a form that's a little easier to read.

So in short, this consists of gathering all available options for the product in question, formatting it into a left and right unordered lists (right and left assuming, of course, that floats and widths are set properly).

The columns are "balanced" in terms of number of itmes, but in my test case, it just so happens that many items in the left column wrap to the next line while most items in the right line don't, so it's not trule balanced.

aid is the attribute number, then it uses a join on the product options table to get which options for this attribute are active.

Computed Code:

$result = db_query("select ao.name from {uc_product_options} as po, {uc_attribute_options} as ao where ao.aid='1' AND ao.oid=po.oid AND nid='%d' order by `name`", $node->nid);

$items = array();
while ($row = db_fetch_object($result)) 
{
  $items[] = check_plain($row->name);
}
if (empty($items)) 
{
 $node_field[0]['value'] = '';
} 
else 
{
  $num_options = count($items);
  $leftside = '';
  $rightside = '';
  $colsize = intval($num_options/2);

  for ($i=0; $i<$colsize; $i++) 
  {
      $leftside .= '<li>' . $items[$i] . '</li>';
  }
  $leftside = '<ul class="left half">'. $leftside . '</ul>';
  for ($i=$colsize; $i<$num_options; $i++) 
  {
      $rightside .= '<li>' . $items[$i] . '</li>';
  }
  $rightside = (empty($rightside)) ? '' : '<ul class="right half">'. $rightside . '</ul>';
$items = array();
  $node_field[0]['value'] = $leftside . $rightside;
} 

Display field

$display = $node_field_item['value'];

For now I'm not storing these values.