I'm doing a website with PHP and HTML in which users upload photos with a title, an address, location and a description.
In addition, there is a button to vote on said photo.
The problem I'm having on that button. I can not get the SQL field to increase by 1 when I press the button.
Try using the post method as a form and have another PHP document handle the query and update the value in the MySQL table.
HTML:
<form name="relevanteBoton" method="post" action="rel.php">
<input type="submit" value="Votar!">
</form>
PHP:
$id = $_POST['id'];
mysql_query("UPDATE 'fotos' SET 'relevancia=relevancia + 1' WHERE 'id = $id'");
I still do not understand deeply the consultations prepared with PDO. This did not work for me. I do not know if I will be doing anything or have some agreement. I do not know much about PHP or MySQL.
I also tried using AJAX and did not get good results.
<script type="text/javascript">
<!--
function incrementar()
{
$.ajax({
url: "rel.php",
context: document.body
}).done(function() {
alert('incremented');
});
return false;
}
-->
HTML:
<span id="button" onclick="javascript:return inc_counter();">Votar!</span>
How could I solve it?