Hi

can anyone help me with this ? Im trying to create a page that lets a user click a link and once that link has been clicked the page no longer displays that link for that user, i have all the databases set up to record clicks but i cant seem to get the PHP code to not display the clicked links, The code im using is as follows:

<?PHP
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['logged_in'])
   || $_SESSION['logged_in'] !== true) {

   // not logged in, move to login page
   header('Location: login.php');
   exit;
}

echo "Welcome "; echo $_SESSION['user_logged'];

// Connect to the database
include("sql.php");

$check_user_info = mysql_query("select * from tracking");
$check = mysql_query("select * from members where members.username ='toasty'");

$x = mysql_fetch_array($check);

$vised = explode(",",$x['adid']);
foreach($vised as $vised1)
{
	 
 $check_array = array_search($vised1, $vised);
  if (!$check_array)
	{
		while ($row = mysql_fetch_row($check_user_info))
		{
			if ($vised1 != $row[1])
			{
			echo "<BR><a href='testframe1.php?id=$row[1]'>$row[3]</a>";
			}
		}
	}				
}

?>

any help would be great thanks.

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?

Thank you so much digital-ether that done the trick perfectly :)

Thank you so much digital-ether that done the trick perfectly :)

:)