Delete statement in self call not deleting



The problem in cases like this is almost always a WHERE clause that fails. Echo your query and see if it looks like you expect. Paste it into your MySQL client of choice. See how many rows it deletes, or if you get an error. Paste it here.
Ah. What I usually tell people in your position is this: Give up on MySQL for the next 2-4 weeks and go back to learning PHP. Far too many people spend a week learning PHP and then dive in MySQL, which is kind of like spending an hour in a simulator and then trying to fly a F16. That's my real recommendation.

But since nobody ever takes my advice, I'll answer your question. You assigned your query to a variable $sql. So if you want to echo the query, this is what you should do:

echo $sql;