Hey guys i found my problem, now i need help how to solve it. I get one person from data base by rand and after clicking like button it should like current number that it shows, but its not. It likes next number that shows after clicking button i dont know how to display it better. Here's my code
<?php
include_once 'session.php';
include_once 'dbh.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="cs.css">
</head>
<body>
</body>
</html>
<?php
$sql = "SELECT * FROM users ORDER BY RAND () LIMIT 1 ; ";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck> 0){
$row = mysqli_fetch_assoc($result);
$ide = $row['idUsers'];
echo $ide;
if(isset($_POST['like'])){
$sql1= "INSERT INTO likes (id, likes)
VALUES ('1', '$ide')";
if ($conn->query($sql1) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: ".$sql1."<br>". $conn->error;
}
$conn->close();
}
}
?>
<form action ="" method="post">
<button value = "like" name="like">like</button>
</form>
Aucun commentaire:
Enregistrer un commentaire