$sql = "select r.tReply,nDeptid,t.vTitle,t.nUserId,t.tQuestion,t.vRefNo,t.vStatus from sptbl_replies as r, "; $sql .= "sptbl_tickets as t where r.nTicketId=t.nTicketId and r.nReplyId='" . mysql_real_escape_string($var_rid) . "'"; $result = executeSelect($sql, $conn); if (mysql_num_rows($result) > 0) { $var_row = mysql_fetch_array($result); $var_deptid = $var_row["nDeptid"]; $var_tickettitle = $var_row["vTitle"]; $var_tqusetion = $var_row["tQuestion"]; $var_refno = $var_row["vRefNo"]; $var_userid = $var_row["nUserId"]; $var_replymatter = $var_row["tReply"]; $var_status = $var_row["vStatus"]; } else { $var_message = "<font color=red>" . MESSAGE_RECORD_ERROR . "</font>"; } $var_replymatter = $var_signature . "\n######################################\n" . replacestr($var_replymatter); $var_ereplymatter = $var_signature . "\n######################################\n" . replacestrforemail($var_replymatter); $var_qtrp = $var_signature . "\n######################################\n" . $var_replymatter; } else { if ($var_rp == "r") { $var_staffid = $_SESSION["sess_staffid"]; $sql = "select tSignature from sptbl_staffs where nStaffId='" . mysql_real_escape_string($var_staffid) . "'"; $result = executeSelect($sql, $conn); $var_row = mysql_fetch_array($result); $var_signature = $var_row["tSignature"]; mysql_free_result($result); $sql = "select nDeptid,vTitle,nUserId,tQuestion,vRefNo,vStatus from sptbl_tickets where nTicketId='" . mysql_real_escape_string($var_tid) . "'"; $result = executeSelect($sql, $conn); if (mysql_num_rows($result) > 0) { $var_row = mysql_fetch_array($result); $var_deptid = $var_row["nDeptid"];
$sql .= "sptbl_tickets as t where r.nTicketId=t.nTicketId and r.nReplyId='" . mysql_real_escape_string($var_rid) . "'"; $result = executeSelect($sql, $conn); if (mysql_num_rows($result) > 0) { $var_row = mysql_fetch_array($result); $var_deptid = $var_row["nDeptid"]; $var_tickettitle = $var_row["vTitle"]; $var_tqusetion = $var_row["tQuestion"]; $var_refno = $var_row["vRefNo"]; $var_userid = $var_row["nUserId"]; $var_replymatter = $var_row["tReply"]; $var_status = $var_row["vStatus"]; } else { $var_message = MESSAGE_RECORD_ERROR; $flag_msg = "class='msg_error'"; } $var_replymatter = nl2br($var_signature) . "\n######################################\n" . replacestr($var_replymatter); $var_ereplymatter = nl2br($var_signature) . "\n######################################\n" . replacestrforemail($var_replymatter); $var_qtrp = nl2br($var_signature) . "\n######################################\n" . $var_replymatter; } else { if ($var_rp == "r") { $var_staffid = $_SESSION["sess_staffid"]; $sql = "select tSignature from sptbl_staffs where nStaffId='" . mysql_real_escape_string($var_staffid) . "'"; $result = executeSelect($sql, $conn); $var_row = mysql_fetch_array($result); $var_signature = $var_row["tSignature"]; mysql_free_result($result); $sql = "select nDeptid,vTitle,nUserId,tQuestion,vRefNo,vStatus from sptbl_tickets where nTicketId='" . mysql_real_escape_string($var_tid) . "'"; $result = executeSelect($sql, $conn); if (mysql_num_rows($result) > 0) { $var_row = mysql_fetch_array($result); $var_deptid = $var_row["nDeptid"];