Changing error message to pop up message
<p>I am having a problem resolving my code here.. I've seen this code and edit it by my self but I want to change the error message to pop up alert, by the client entered an existing value after submitting the pop up message will appear and say Sample Code is already in use</p>

<pre><code>if($scode != '') {
    $qry = "SELECT * FROM toxintablemonitoring WHERE sampleCode='$scode'";
    $result = mysql_query($qry);
    if($result) {
        if(mysql_num_rows($result) &gt; 0) {
            $errmsg_arr[] = 'Sample Code already in use';
            $errflag = true;
        }
        @mysql_free_result($result);
    }
    else {
        die("Query failed");
    }
}

if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: sample_input_monitoring_toxin.php");
    exit();
}
</code></pre>
