JS
<script>
function myAjax() {
$.ajax({
type: "POST",
url: 'ajax.php',
data:{action:'call_this'}
});
</script>
HTML
<a href="'. $row['link'] .'"target="_blank" onclick="myAjax()">
PHP
<?php
require ("static/php/inc/betaconfig.inc.php");
if($_POST['action'] == 'call_this') {
$conn->query("UPDATE users SET clicks = (clicks + 1) WHERE id = 13");
}
?>
通常它应该是$ uid而不是13,但我也不知道如何做到这一点......
首先,为什么这不起作用?第二个$ uid是$id = $_REQUEST['id'];
,然后是
$sql = "SELECT * FROM `link` WHERE id = '$id'";
$result4 = $conn->query($sql);
while($row = $result4->fetch_assoc()) {
$uid = $row['userid'];
}
所以最好的事情是,而不是13我可以使用$ uid