foreach($vised as $vised1)
{
$check_array = array_search($vised1, $vised);
if (!$check_array)
There is an error (2 actually) in the logic in the part above.
The check $check_array = array_search($vised1, $vised); always checks for a value $vised1 that is always present in $vised, since the foreach() loop goes through each index of $vised, and saves a copy of the value to $vised1.
The part above can be rewritten as:
foreach($vised as $check_array=>$vised1)
{
if (!$check_array)
The other problem I think is that you're thinking $check_array returns true or false? Instead it returns the index. So if you were actually checking if a value existed in an array, you'd use:
if ($check_array !== false)
which will also check for the TYPE to make sure it is the same type on each side of the comparison operator.
Otherwise when an index such as 0 or ' ' exist in an array, those indexes are casted to boolean before the comparison is made, thus you get a false when the index actually exists.
I'm not sure exactly how you're going about this, but it should probably something like:
$links = mysql_query("select * from tracking"); // is this all the links (the larger set)?
$clicked = mysql_query("select * from members where members.username ='toasty'"); // is this the links already clicked (smaller set) ?
$x = mysql_fetch_array($clicked); // id's of clicked links?
$vised = explode(",",$x['adid']);
while ($row = mysql_fetch_row($links))
{
$check_array = array_search($row[1], $vised); // check if column 1 exists in the visited links
if ($check_array !== false)
{
echo "<BR><a href='testframe1.php?id=$row[1]'>$row[3]</a>";
}
}
I have the comments in the code on my assumptions. Could you post the db table structures or explain on which holds what for clarification?