I have problem updating the mySQL table i have simple loop to display the rows in the table in HTML FORM but when i try to update the row notting happens, no row is updated!
here is the code
<form action="" method="post">
<?php
$sql = "SELECT ID, votemodelName, votemodelImage, modelLink, votes, ip_address FROM vote ORDER BY ID LIMIT 3";
$result = $conn->query($sql);
$user_ip = getenv('REMOTE_ADDR');
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
if (!$result) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$ID = $row["ID"];
$votemodelName = $row["votemodelName"];
$votemodelImage = $row["votemodelImage"];
$modelLink = $row["modelLink"];
$votes = $row["votes"];
$ip_address = $row["ip_address"];
?>
<div class="col-xs-4 col-md-4">
<a href="<?= $modelLink ?>" target="_blank" class="thumbnail">
<img src="<?= $votemodelImage ?>" class="thumb-vote-image" alt="Amanda">
</a>
<h1><button type="submit" name="vote_<?= $ID ?>" class="btn btn-info btn-lg">VOTE</button></h1>
<h3><?= $votemodelName ?></h3>
</div>
<?php
}
if(isset($_POST["vote_".$ID])) {
$voteModel = $_POST["vote_".$ID];
$sql = "UPDATE vote SET votes = votes + 1 WHERE ID='".$voteModel."'";
$result = $conn->query($sql);
}
}
?>
</form>