Jump to content

Recommended Posts

Hello folks,

 

I just joined the forums - looks like quite a valuable resource here.  :-*

 

I'm having trouble with some html/php I just wrote...this is an extremely strange bug - hoping someone can shed some light.

 

I have this code:

 

if($sequence == 1) return "<a href='".movedown($sequence)."'><img src='down_arrow.gif'></a>";

 

Which in english translates to: if the sequence variable (pulled from the database) is equal to one, show a image called down_arrow and make that image link to a php function called movedown.

 

Problem is... the movedown function is firing on page refreshes (it's not waiting for me to click it).

 

Inside of the movedown function, there is an SQL statement that increments the sequence in the database. Good news is, that the function works, bad news is - it's incrementing without me clicking the down_arrow image!

 

Any ideas?

 

Thanks all,

 

JA

php is server-side.  It parses and sends results to the client.  You cannot make it wait to call the php function until you click it like that.  You have to call a javascript function instead, and in that javascript function, call a php script that executes the function.

Hello Crayon,

 

Since PHP is server side, and Javascript is client side - how do you propose I send data from one to the other?

Must I POST the data?

 

Please provide an example.

 

Cheers & Thanks for your help.

 

JA

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.