As I see it, the fine is in the right place allready. The fine is after all not related to a specific book, but rather a specific loan of said book, so it belongs in the loan table.
For the code posted by bradgrafel there is no need to insert additional code, unless you want to provide some kind of feedback to the user since the SQL statement allready updated the table.
But, with this approach, the table is updated when a book is actually returned (and you find out the borrowi_id). So, for a book which is never returned, there would be no fine added. Which works fine as well, but it does mean that you can't see what books (should) have fines on them through SELECT stuff FROM bookoutonloan WHERE amountoffine > 0. And personally I find this counterintuitive.
I'd rather
1. change datereturned to allow null values. Else, how will you represent a book which has not yet been returned?
2. Change bradgrafelmans's SQL statmeent to
UPDATE bookoutonloan SET amountoffine = amountoffine + 10 WHERE DATE_ADD(datedueforreturn, INTERVAL 1 MONTH) < CURDATE() AND datereturned IS NULL";
and run this code every day at midnight.
But, if you decide to stick with his approach, then yes, you execute that statement when a book is returned. You will need to get the information regarding the lates loan of this book. For the above, all you need is the bookid, but you probably want to display other information to the user, such that the date when it should have been returned etc. Thus
"SELECT stuff FROM bookoutonloan WHERE bookid = $bookid ORDER BY datedueforreturn DESC LIMIT 1"