Script it with your language of choice (PHP, ASP, etc.). When the user clicks on a link, the script would record some info and route the person to the destination. Very similar to an affiliate link, in terms of coding.
Best bet if you are new to programming: PHP and MySQL. They are both fast, efficient, and easy to use. When combined, they become a super powerful pair and you can do so much with them.
I'd say you should make a system based on impressions and clicks. That's a very competitive business so be sure you make some features that set your PPC search engine apart from the others. I'm not a very idealistic person when it comes to that (for free at least ), so you are on your own there. I would recommend using PayPal's IPN system, for users to buy their links and such, though.