Trying to select the clicked div's id with jQuery and insert it to mysql so I can load the right content on the next page but the insert does not get any value. I get the right id by the alert function and the insert is working fine with an actual number but I need the one that the user clicked on.
$(function() {
$('.current_content').click(function() {
alert($(this).attr('id'));
<?php
$content_id_insert = "INSERT INTO selected_content (content_id) VALUES(?>$(this).attr('id')<?php)";
$conn->query($content_id_insert);
?>
document.location = 'content.php';
})
})
And the div:
<div class="current_content" id="<?php echo($row['id']); ?>">
...
</div>