I am trying to check if there is a entry from today and if not then add one, if it already exists then not. Current code is:
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql .= "SELECT plusamount AS plustotal, minusamount AS minustotal FROM Juuli WHERE reg_date >= CURRENT_DATE() ORDER BY id DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "It already exists!";
} else {
echo "autowrite should run";
$sql .= "INSERT INTO Juuli(minusamount) VALUES (0); ";
}
$conn->close();
?>