Some little help with php-script on send button

I have created an extra table in the Joomla database which contains a membership number. Via a query I can show this number on the form, and in the mail and pdf which is send to the admin.
Now I want to increase this number every time someone fills in the form. I am not a programmer but Google is my friend. But I can't find the correct php script to accomplish this.
Can you point me in the right direction?
The query to read the number is:
[SQL query = SELECT membership_number FROM jos_members;]

And for the submit button I need something like this:
$currentMembershipNumber = $row['membership_number'];
// Increment the membership number
$newMembershipNumber = $currentMembershipNumber + 1;
// Update the database with the new membership number
$updateQuery = "INSERT INTO jos_members (membership_number) VALUES ($newMembershipNumber)";

Regards, Peter

Replies are visible only to logged in members with an active subscription.