Jump to content

javascript and php - updating a record everytime a javascript function is run


Bhaal

Recommended Posts

Yeah...I know that javascript is client side and PHP is server side - hence the reason I'm posting this.

 

I found a pretty nice MP3 player that can be 'fed' an MP3 by a javascript function.  I'm using PHP to query a table, then telling the javascript which MP3 to play based on the results of that query.

 

So...

 

I run a simple select query, then populate a variable:

 

$demoName = "'" . $a2[url_path] . $a2[demo_file_name] . "'";

 

Then the MP3 player is invoked by the following link:

 

<a href='javascript:void(0);' onclick='javascript:loadFile($demoName);return false;'>Play</a>

 

The function "loadFile" is pretty simple:

 

function loadFile(fil) {
thisMovie("mp3player").loadFile(fil);
};

 

(The referenced function "thisMovie" just identifies the instance of the MP3 player.)

 

What I would LOVE to happen is that each time this javascript is run, a counter field for that MP3 is increased by one, something like:

 

$query = "UPDATE mp3s SET count=count+1 WHERE mp3_id=$id"

 

I pretty much understand all that code I just don't know how to make them work "together".  Is there a way to run that update query after the javascript function is run?

 

Any help is greatly appreciated!

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.