I have values in database like these :
Row 1 : ["2","3"]
Row 2 : ["1","3"]
Row 3 : ["2","3","4"]
In frontend i selected all rows, now i want to show count of similar values. For eg : Desired o/p from above code : Count for 1 = 1 , 2 = 2 , 3 = 3 , 4 = 1
When i json_decode above values and using print_r i got like these :
Array ( [0] => 2 [1] => 3 )
Array ( [0] => 1 [1] => 3 )
Array ( [0] => 2 [1] => 3 [2] => 4 )
Note : List of rows can be increased, how can i find similar values.
I tried array_intersect as shown here , but didn't work.
Eg: image here Please Note Data in image, is different from above data
Code to get above data :
$conn = new mysqli("localhost", "root", "", "ams");
$query="SELECT * FROM attendance WHERE subject = '$subj'";
$result = $conn->query($query);
<table class="table table-responsive">
<tr>
<th>Sr. No</th>
<th>Col 1 </th>
<th>Col 2</th>
</tr>
<form method="post">
<?php
$i=1;
if (mysqli_num_rows($result) > 0) {
while ($row=mysqli_fetch_assoc($result)) {
$data = $row['att'];
$data = json_decode($data);
echo "<tr>";
echo "<td>" . $i . "</td>";
echo "<td>" . $row['date1'] . "</td>";
echo "<td>" . print_r($data) . "</td>";
echo "</tr>";
$i++;
}
}
?>
</form>
</table>