$output.="<th>Action</th>"; // field for menu icons
// Title: Grab the list of field names
$new_order_dir = $order_dir=='DESC' ? 'ASC' : 'DESC'; // next click reverse order
$fields=$res->fetch_fields();
foreach ($fields as $field) {
# Simple titles:
#$output.="<th>". $field->name . "</th>";
# other attributes: table, max_length, flags, type
// Titles with clickable sort links:
$output.=<<<TXT
<th class='light'>
<a href="{$this->calling_script}?sortlimit={$limit}&sortby={$field->table}.{$field->orgname}&order_dir={$new_order_dir}&searchstring=$searchstring&searchby=$searchby&change=Change" title="Sort by this column">$field->name</a>