How can i populate the record in to table using shell scripting?

LOG_DIR=/app/rpx/jobs/scripts/just/logs
  sendEmail()
    {
        pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7"
        (
          echo "From: $pzFrom\nTo: $pzTo\nSubject: $pzTitle${pzReplyTo:+\nReply-To: $pzReplyTo}"

              [[ -n "$pzCType" ]] && echo "Content-Type: $pzCType"

              echo
               echo "$pzMsg"
                  [[ -n "$pzFiles" ]] &&
                  echo &&
                  for pzFile in $pzFiles
                  do
                    [[ -f "$pzFile" ]] && uuencode "$pzFile" "$pzFile"
                  done

                ) | mail "$pzTo"
          }

## all pending subscriber .

pending=`sqlplus -s pag_app/abc@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set heading off;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;
select msisdn,status_changed_time,rate_plan_id,status from subscriber where status = 'P' and status_changed_time < sysdate - 1/24 or
der by status_changed_time  desc;
EOF`
echo "<html>" >final.html
echo "<table border="1" border-cols -altrapse:collapse>" >>final.html
echo "<tr>" "<th bgcolor="#FF8C00">MSISDN </th>" >> final.html
echo "<th bgcolor="#FF8C00">Status Changed Time</th>">> final.html
echo "<th bgcolor="#FF8C00">Rate Plan</th>">> final.html
echo "<th bgcolor="#FF8C00">Status</th>">> final.html
echo "</tr>" >> final.html
#echo "<tr>"$msisdn "</tr>">> final.html
echo "</table>" >> final.html
echo "</html>" >> final.html

body=`cat final.html`
{
echo "From: ankit.gupta92@t-mobile.com "
echo "To: ankit.gupta92@t-mobile.com"
echo "Subject:Hello"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
echo "$body"
echo "$pending"
} |/usr/sbin/sendmail -t
#sendEmail '' "Pending_Activating" "$final" 'ankit.gupta92@gmail.com' 'ankit.gupta92@gmail.com' "final.html" ' '
exit 0;

My output is as below, but i tried to put output inside the table but its not coming, as query result will be different daily, i need that all query output should populate inside table

Looks like you don't really heed advice given to you in other threads. Please check the correct nesting of the HTML tags.