I understand what you are saying.
when a callerCaller calls, You would like to have query that would capture the number then go back to a DB and find the name and a pic of the calller that is assochiated with incoming number. You would enter the info your self for the query to run aginst after the number is capterd.
Fisrt things first.
Again not to be redundent but you need to have the TELCO that you are using turn on Caller ID so the number can be sent to you. Have you done this?
If the telco is not sending the caller information to you then you will never see the caller infromation. This is the first step in getting this done.
I think your idea is a cool one.