id = 1;
echo "";
if (!$hid) {
   $x = db_query("select id,date,header.from from header where uid=$user->id order by id");
   if (mysql_num_rows($x)>=1) {
	  echo "
";
	  echo "| Msg ID | Date | From | 
|---|
";
	  while($r = mysql_fetch_object($x)) {
		 echo "| $r->id | $r->date | $r->from | 
";
	  }
	  echo "
";
   }
} else {
   // find next and previous
   $x = db_query("select id from header where uid=$user->id and id>$hid order by id asc limit 1");
   $next = mysql_fetch_object($x);
   $x = db_query("select id from header where uid=$user->id and id<$hid order by id desc limit 1");
   $previous = mysql_fetch_object($x);
   $x = db_query("select id,bid,date,header.from,text from header where id=$hid and uid=$user->id order by header.from,date");
   if (mysql_num_rows($x)==1) {
	  $r = mysql_fetch_object($x);
	  $y = db_query("select id,body from body where id=$r->bid");
	  if (mysql_num_rows($y)==1) $s = mysql_fetch_object($y);
	  else die("Error, can't find that body.");
   } else die("Error, can't find that header.");
   print "";
   print "
$s->body
";
}