Jump to content

Recommended Posts

hi .

i have this code for counting each profile views and avoid to increment by refresh

but i have problem here . since array_merge start with his own index i can't determine

my specific id is in the array or not . so i want to what function can i use to determine a value in array or not . instead of using in_array function .

 

 

<?php 
//product view counter:


		//init array 
		$ID = array();
		$ID[$pid] = $pid ; 

					//debug 
					echo '<pre>' ; print_r($ID); echo '</pre>' ; 


		//init session 
		if(isset($_SESSION['ID'])):
		$_SESSION['ID'] = array_merge($_SESSION['ID'] , $ID ) ; 
		else:
		$_SESSION['ID'] = $ID ; 
		endif; 

					//debug 
					echo '<pre>' ; print_r($_SESSION['ID']); echo '</pre>' ; 

		//check for sessions 
		if(!in_array($_SESSION['ID'] , $ID[$pid])):

			//ok session not exist go ahead query db 
				$num = $db->get_var("select xviewnum from xxprofile where xprofileid='$pid'") ; 
				$num += 1 ; 
				$db->query("update xxprofile set xviewnum='$num' where xprofileid='$pid'") ;
		endif; 



	//END product view counter 	




?>

 

tanks for helping

 

you can always pull a foreach on it and set a boolean

foreach($array as $value)
    $in_array = $value == "Search Term" ? true : false;

if($in_array) {
//do stuff
....
..............
} else {
.....................//do stuff
...?
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.