Daisy Posted May 19, 2006 Share Posted May 19, 2006 Hi everyoneI am new to PHP so bare with me :(I am using swish to write flash sites and what I need is a way to log clicks for certain "links".Currently I am using a PHP script that allows me to do this but I have to have a seperate PHP and a seperate .txt file just to log a click number for each link/button.What I would like to know is, if there is a way just to write to one log file but to have each link with a diffrent iD tag so in the log file it shows, for example: ID=link1 clicked 10 times ID=link2 clicked 5 times.....etc etcHope someon can clear me on thisThanksDaisy Quote Link to comment https://forums.phpfreaks.com/topic/9965-php-swish/ Share on other sites More sharing options...
litebearer Posted May 19, 2006 Share Posted May 19, 2006 Not sure but is this kind of what you had in mind?the text file (button,score|button,score| etc etc)(buttonclicks.txt)[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]01,3|02,25|03,17|04,18[/quote]the php file[code]<?PHPfunction add_clicks($file,$what_button) { $contents = file_get_contents($file); $new_array=explode("|",$contents); $i=0; for($i=0;$i<count($new_array);$i++) { $done = FALSE; $temp_array = explode(",",$new_array[$i]); if($temp_array[0] ==$what_button) { $score = $temp_array[1]; $temp_array[1] = $score + 1; $new_array[$i] = implode(",",$temp_array); $i = count($new_array); $done = TRUE; } } $contents = implode("|",$new_array); $fp = f open($file, "w"); $write = f puts($fp, $contents); f close($fp); return $done;}############################## this is the name of the text file# that keeps count of the clicks#############################$file = "buttonclicks.txt";################################ replace the value of this variable# with how you set the value of# the button clicked###############################$what_button = 3;########################################### run the function# if its not sucessful (FALSE) so something# if its successful (TRUE) do something else##########################################$done = add_clicks($file,$what_button);if(!$done) { echo "Too bad";}else{ echo "Well done!";}?>[/code]Note: the forum is still having difficulties with file operation scripts, so remove the spaces after each 'f' in the file operationsHope this helps.Lite... Quote Link to comment https://forums.phpfreaks.com/topic/9965-php-swish/#findComment-37060 Share on other sites More sharing options...
Daisy Posted May 19, 2006 Author Share Posted May 19, 2006 Hi Litemany thanks for the response.Ok. I am not too clued when it comes to PHP but most of this makes sense. But the more I look at it the les it does! hahahaSorry if I sound dumb but what value would I have to add to the button in order for it to send the click info to the file?With the old script i have this on the button RELEASE:this.loadVariables("entrar_hit_counter.php?rn=");Which obviously sends it to the PHP file which then writes it to the .txt fileThank you againDaisy Quote Link to comment https://forums.phpfreaks.com/topic/9965-php-swish/#findComment-37101 Share on other sites More sharing options...
litebearer Posted May 19, 2006 Share Posted May 19, 2006 it all depends upon how YOU want your coding to be.ie the simplest method (IMHO) would be to assign each button a unique numeric value. then pass this value to your php script via the post method.Lite... Quote Link to comment https://forums.phpfreaks.com/topic/9965-php-swish/#findComment-37133 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.