The point of hashes is that they're not decodeable. The functions to use are either MD5 (for the older system) or SHA1 (for a more recent hash) to encode the plaintext passwords.
So what you do is, you store the passwords in hashed form in the DB. Yes, that means that you will never know the passwords of the users. Yes, that also means that you have to supply a function that resets the users password in the DB.
In the script you only have to see that you encode the provided password everytime before you do anything with it, be it storing into the DB or comparing it with the DB-content.
Best to take devinemke's example:
$pass = sha1($password);
$sql = "SELECT * FROM Users WHERE userid = '{$UserID}' AND password = '{$pass}'";