Jump to content

PHP & Swish?


Daisy

Recommended Posts

Hi everyone

I 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 etc

Hope someon can clear me on this

Thanks

Daisy

Link to comment
Share on other sites

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]
<?PHP

function 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 operations

Hope this helps.

Lite...
Link to comment
Share on other sites

Hi Lite

many 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! hahaha

Sorry 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 file

Thank you again

Daisy

Link to comment
Share on other sites

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.