onclick funtion to run sql query and update records in background

hi
i m having a dating site, wherein there is link view contacts, once clicked it shows contact details of respective member.
now as its a membership site, paid members are alotted limited number of contact views, after that they are restricted.
Now i m having a link View contacts which on click shows popup box with details, i m using javascript: termsFunction2(); for this... now what i want is an onclick function like when the link is clicked a sql query for update should run in background and updates the no. of contacts viewed in database.
the view contact popup box opens without page refresh....

below is the code i m using for pop up
<style>
		@import "popup/Assets/LightFace.css";
	</style>
	<link rel="stylesheet" href="popup/Assets/lightface.css" />
	<script src="popup/mootools.js"></script>	
	<script src="popup/mootools-more-drag.js"></script>
	<script src="popup/Source/LightFace.js"></script>
    <script src="popup/Source/LightFace.IFrame.js"></script>
 
	<script>
		
	 	function formFunction() {
	 		return new LightFace({
	 			title: $('demo1title').value,
	 			content: $('demo1content').value,
				draggable: true
	 		}).open();
	 	}
 
	 			function termsFunction2()
		{
	  		box = new LightFace({ 
	 			title: 'Contact Details of Bhavin Patel (S1078)', 
				width: 700,
				height: '100%',
	  			content: '<table><tr><td>Mobile</td><td>********** Upgrade Membership to view Mobile No.</td></tr><tr><td>Landline</td><td>+91-79-</td></tr><tr><td>Email Address</td><td>bhavin_2511@yahoo.com</td></tr><tr><td>Name of Contact Person</td><td>Tarak Patel</td></tr><tr><td>Relationship with the member</td><td>Self</td></tr><tr><td>Convenient Time to Call</td><td>1&nbsp;AM to 2&nbsp;PM</td></tr><tr><td>Contact Numbers Balance</td><td>Viewed - 0&nbsp;|&nbsp;Balance - 100</td></tr></table>',
	 			buttons: [
					{ 
						title: 'Close', 
						event: function() { this.close(); },
						color: 'blue'
					}
				]
	 		});
	 		box.open();		
	 	}	
		
	</script>

 <a href="javascript: termsFunction2();">View Phone No.</a>

Open in new window

LVL 1
global_expert_adviceAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

betawarzCommented:
Your client-size Javascript will not be able to directly access your database. You will need to execute an Ajax request to your web server, at which point you can update your database and return the new value to the user. Then, you will be able to modify the DOM to reflect the changes.
0
teedo757Commented:
I would just create an ajax function to update the database based off the onclick event.
http://www.w3schools.com/php/php_ajax_database.asp
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
global_expert_adviceAuthor Commented:
did the trick.
thanks
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.