You're mixing php with javascript, which is not allowed. Try either of the two options below to escape your javascript from php.
$cnt= mysql_num_rows($qry_resultcnt);
if ($ttrec >=1) {
echo "msgbox";
echo '<script>document.getElementById("btn1").disabled = true;</script>';
}
Or....
$cnt= mysql_num_rows($qry_resultcnt);
if ($ttrec >=1) {
echo "msgbox";
?>
<script>
document.getElementById("btn1").disabled = true;
</script>
<?php
}
Although for both options, I would recommend wrapping your JS in a self invoking function so that you are certainly firing it, like so...
echo '<script> (function() { document.getElementById("btn1").disabled = true; })(); </script>';
OR....
<script>
(function() {
document.getElementById("btn1").disabled = true;
})();
</script>