[wd_asp elements=’search’ ratio=’100%’ id=1]

Show rows affected by mysqli

28th February 2020

MySql

mysql codehaven category

Nice bit of code that shows how many rows were deleted, if any!

Note: If the data to be written is the same it will show “0 records added”


echo $sql = "UPDATE todolist SET list = '$movetolist' WHERE item = '$itemtext' ";
if ($mysqli->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "
" . $sql->error;
}

echo "Affected rows: " . $mysqli -> affected_rows;