FromSubject/Message"; $q = mysql_query( "SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid ORDER BY mail_time DESC ", $c); while ($r = mysql_fetch_array($q)) { $sent = date('F j, Y, g:i:s a', $r['mail_time']); print ""; if ($r['userid']) { print "{$r['username']} [{$r['userid']}]"; } else { print "SYSTEM"; } print "\n{$r['mail_subject']}Sent at: $sent
{$r['mail_text']}"; } print ""; } else if ($_GET['a'] == 'outbox') { // We'll be outputting a PDF header('Content-type: text/html'); // It will be called downloaded.pdf header( 'Content-Disposition: attachment; filename="outbox_archive_' . $userid . '_' . time() . '.htm"'); print ""; $q = mysql_query( "SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_to=u.userid WHERE m.mail_from=$userid ORDER BY mail_time DESC", $c); while ($r = mysql_fetch_array($q)) { $sent = date('F j, Y, g:i:s a', $r['mail_time']); print ""; } print "
ToSubject/Message
{$r['username']} [{$r['userid']}]{$r['mail_subject']}
Sent at: $sent
{$r['mail_text']}
"; }