$ts_expense_verified = "<a href=\"index2.php?page=datebook_view_day&amp;time={$ts_expense_verified}\">" . TimeFormat($ts_expense_verified) . "</a>";
         } else {
             $ts_expense_verified = "--";
         }
         $user_initials = $array['user_initials'];
         print "<tr><td><a href=\"index2.php?page=datebook_view_day&amp;time={$ts_expense_date}\">" . TimeFormat($ts_expense_date) . "</a></td><td>{$ts_expense_verified}</td><td style=\"width: 50%;\"><a href=\"index2.php?page=timesheet_expense_view&amp;ts_expense_id={$ts_expense_id}\">{$ts_expense_desc}</a>";
         if ($ts_expense_notes != NULL) {
             echo "<br />Notes: {$ts_expense_notes}";
         }
         echo "</td><td>" . MoneyFormat($ts_expense_vat) . " [ID: {$ts_expense_id}]";
         print "<td>{$user_initials}</td></tr>";
     }
     echo "</table>";
 }
 // Tender submissions
 $sql = "SELECT answer_id, answer_response, answer_tender_id, answer_ref, tender_name, tender_date FROM intranet_tender_answers, intranet_tender WHERE " . SearchTerms($keywords_array, "answer_response") . " AND tender_id = answer_tender_id ORDER BY tender_date DESC";
 $result = mysql_query($sql, $conn) or die(mysql_error());
 echo "<table>";
 if (mysql_num_rows($result) == 0) {
     print "<tr><td>No results found for Tenders</td></tr>";
 } else {
     print "<tr><td><strong>Tender Submissions</strong></td></tr>";
     while ($array = mysql_fetch_array($result)) {
         $answer_id = $array['answer_id'];
         $answer_response = strip_tags($array['answer_response']);
         $answer_tender_id = $array['answer_tender_id'];
         $answer_tender_id = $array['answer_tender_id'];
         $answer_ref = $array['answer_ref'];
         $tender_name = $array['tender_name'];
         $tender_date = $array['tender_date'];
         echo "<tr><td>";
             $user_initials = $array['user_initials'];
             echo "<tr><td><a href=\"index2.php?page=datebook_view_day&amp;time={$ts_expense_date}\">" . TimeFormat($ts_expense_date) . "</a></td><td>{$ts_expense_verified}</td><td style=\"width: 50%;\"><a href=\"index2.php?page=timesheet_expense_view&amp;ts_expense_id={$ts_expense_id}\">{$ts_expense_desc}</a>";
             if ($ts_expense_notes != NULL) {
                 echo "<br />Notes: {$ts_expense_notes}";
             }
             echo "</td><td>" . MoneyFormat($ts_expense_vat) . " [ID: {$ts_expense_id}]";
             echo "<td>" . $user_initials;
             if ($ts_expense_p11d != 0) {
                 echo "&nbsp; [P11d]";
             }
             echo "</td></tr>";
         }
         echo "</table>";
     }
 } else {
     $sql = "SELECT answer_id, answer_question, answer_response, answer_tender_id, answer_ref, tender_name, tender_date FROM intranet_tender_answers, intranet_tender WHERE ( " . SearchTerms($keywords_array, "answer_response") . " AND tender_id = answer_tender_id ) OR ( " . SearchTerms($keywords_array, "answer_question") . " AND tender_id = answer_tender_id ) AND answer_complete = 1 ORDER BY tender_date DESC, tender_name ";
     $result = mysql_query($sql, $conn) or die(mysql_error());
     if (mysql_num_rows($result) > 0) {
         echo "<table>";
         echo "<h2>Tender submissions (only answers marked as complete are shown below)</h2>";
         while ($array = mysql_fetch_array($result)) {
             $answer_id = $array['answer_id'];
             $answer_response = strip_tags($array['answer_response']);
             $answer_tender_id = $array['answer_tender_id'];
             $answer_question = strip_tags($array['answer_question'], "<p><br><ul><li>");
             $answer_question = preg_replace('/(<[^>]+) style=".*?"/i', '$1', $answer_question);
             $answer_question = preg_replace('/(<[^>]+) class=".*?"/i', '$1', $answer_question);
             $answer_question = preg_replace('/(<[^>]+) align=".*?"/i', '$1', $answer_question);
             $answer_ref = $array['answer_ref'];
             $tender_name = $array['tender_name'];
             $tender_date = $array['tender_date'];