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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.