I'm not sure if this answers your question, and I'm still learning mySQL, but the way that I would do it is first, I would have the script find that users htpasswd entry, delete it, and then write a new one like this:
if($new_password)
{
if($filehandle = fopen($file_dir/.htpasswd, "a")
{
$enc_pass = crypt($new_password);
fputs($filehandle, "$username:$new_password");
fclose($filehandle);
print("Password Update Complete");
}
else
{
echo($error);
}
}
I hope that helps, if you want a good script for deleting entries in htpasswd check out http://www.scriptschool.com/php/, he has a good, free, script there that you can modify to your every need.