rxgvhqkrywq6cxdjoar Posted October 17, 2009 Share Posted October 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/177987-href-automatically-calling-php-function-without-click/ Share on other sites More sharing options...
.josh Posted October 17, 2009 Share Posted October 17, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/177987-href-automatically-calling-php-function-without-click/#findComment-938461 Share on other sites More sharing options...
rxgvhqkrywq6cxdjoar Posted October 17, 2009 Author Share Posted October 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/177987-href-automatically-calling-php-function-without-click/#findComment-938465 Share on other sites More sharing options...
awpti Posted October 17, 2009 Share Posted October 17, 2009 Google: Ajax Tutorial Quote Link to comment https://forums.phpfreaks.com/topic/177987-href-automatically-calling-php-function-without-click/#findComment-938473 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.