You should try to separate your Javascript from your HTML as much as possible. Output the vanilla HTML initially and then add the event to the link afterwards.
printf('<td><a id="deleteLink" href="delete.php?id=%d&category=%s">Delete</a></td>', $row["id"], $a);
and then some javascript somewhere on the page:
document.getElementById('deleteLink').onclick = function() {
return confirm("Are you sure you wish to delete?");
};
From your example however, it looks like you've probably got a table with multiple rows, each with its own delete link. That makes using this style even more attractive, since you won't be outputting the confirm(...)
text over and over.
If this is the case, you obviously can't use an id
on the link, so it's probably better to use a class. <a class="deleteLink" ...
If you were using a javascript library such as jQuery this is very easy:
$('.deleteLink').click(function() {
return confirm("...");
});