I have two arrays. In one array, I store data from one table. I store data from another table in the other array. I wanted to compare data from both of the arrays. If the data of the first array is in the second array, I want to proceed. How can I perform this?
I tried the following code but it's not working event though the array1 number exists in array2:
$x = "SELECT * FROM table1";
$data1 = mysqli_query($link, $x);
$dat1 = array()
while($row1= mysqli_fetch_array($data,MYSQLI_ASSOC))
{
$dat1[] = $row1;
$f1 = $row1['fid'];
}
$y = "SELECT * FROM table2";
$data2 = mysqli_query($link, $y);
$dat2 = array()
while($row2= mysqli_fetch_array($data2,MYSQLI_ASSOC))
{
$dat2[] = $row2;
$f2 = $row2['fid'];
}
if(in_array($dat1,$dat2))
{
// if exists proceed
}
else
{
// if not show error
}