使用链接时从SQL中减去的PHP代码

Good Day

I have a link that does the following

<a href="/lbs_map.php" target="_blank" class="update">Find Client</a>

It then runs the required page. I need when the link is used for it to subtract one value from a SQL database I have.

The database has the following Rows

id date credit

$sql = "UPDATE items SET credit = credit - 1";

I have tried entering the above string into the code as such:

<a href="/lbs_map.php" target="_blank" class="$sql = "UPDATE items SET credit = credit - 1";">Find Client</a>

But can't seem to get it to work.

Please assist all I need is one credit to be deducted when the link is used. but the link must still preform the href as well

EDITED:

$sql = "insert into avis_lbs_log set lng = '".$long."', lat = '".$lat."', distance =   
'".$distance."', msisdn = '".$msisdn."', date_time = '".$today."'";
        $sql = "UPDATE avis_credit SET cred = cred - 1'";

You have to fire this query in lbs_map.php to decrement the value

//lbs_map.php

<?php
//mysql connection
$sql = "UPDATE items SET credit = credit - 1";
//execute the sql query
//your rest of code

What you need to do is set up code that doesn't contain your statement. This is to prevent SQL injection. A better way of doing it is:

<a href="/lbs_map.php?do=update" target="_blank" class="update">Find Client</a>

Then in your PHP, you can check if $_GET['do'] == 'update' and perform the update.