Why in_array is not working? I am getting "Not found" even if $tid is in aray.
Thanks.

$result1 = mysql_query("SELECT  id from table WHERE column='$sid'
order by id DESC limit $start, $step");

while($row = mysql_fetch_array($result1))
{
    $resultarray[] = $row;
}


$result2 = mysql_query("SELECT  id from table2 WHERE column='$sid'
order by id DESC limit $start, $step");

while(list($tid) = mysql_fetch_row($result2)) {

 if (in_array($tid,$resultarray))
  {
  echo "Found";
  }
else
  {
  echo "Not found";
  }

}

    $resultarray is an array of arrays. You probably want to write:

    $resultarray = array();
    while ($row = mysql_fetch_assoc($result1))
    {
        $resultarray[] = $row['id'];
    }

    That said, it looks like a join would be appropriate here.

      Write a Reply...