I have this code where am trying to check if all values in the selected rows are the same or not and its just not working
$name = $row['name'];
$sql = "SELECT status FROM testing WHERE name='$name'";
$result = mysqli_query($conn, $sql);
$datas = array();
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$datas[] = $row;
}
}
if (count(array_unique($datas)) === 1 && end($datas) === 'No') {
echo 'all the same';
}
else {
echo 'not all the same';
}
after inserting the values into an array $datas and still trying to check if the value No is the same in all the selected row in the database but it keeps throwing an error
NOTICE: ARRAY TO STRING CONVERSION
Edit: I added this $datas[] = $row['status']; and it worked