0

Initially, as can be seen in this unsuccessful attempt: Undefined index error when sending variable from jquery to php and this unsuccessful attempt:Passing Jquery variable to php within a modal

I was trying to pass a variable from php, to jquery and back to php.

Basically I am generating images form a database in a php loop. When the user selects an image, I want the id of that image to be passed to the modal so that I can query the database again (based on that id) and get more information.

Is there another way of doing this other than the methods outlined in the posts above. For some reason those do not return the result.

The difference between Send PHP variable value to JavaScript popup window in same page and my question is that I want it as a heading.. and as a variable so I can query the database again. I am not using this to input values into a form

Community
  • 1
  • 1
user2883071
  • 960
  • 1
  • 20
  • 50
  • 1
    possible duplicate of [Send PHP variable value to JavaScript popup window in same page](http://stackoverflow.com/questions/28391458/send-php-variable-value-to-javascript-popup-window-in-same-page) – Wesley Smith Apr 28 '15 at 02:06
  • Not a duplicate.. it is different.. I am not using this to populate forms.. I want a variable.. like a `$id` <-- that kind of variable so i can query a database.. I don't want to populate a form with any information! – user2883071 Apr 28 '15 at 02:34
  • It is pretty much a duplicate then, Php only runs when the page loads, if you want to use the variable, you'll need to store it somewhere ( like a data attribute as shown in the linked question) then you'll need to make an Ajax call and pass it that stored value – Wesley Smith Apr 28 '15 at 02:40
  • is there no other way of doing it? for some reasons (as seen in my frst 2 posts) the ajax calls aren't working – user2883071 Apr 28 '15 at 02:43
  • 1
    Please check the answer I posted on your other question http://stackoverflow.com/questions/29881307/passing-jquery-variable-to-php-within-a-modal, and you should probably close this as a duplicate of that question as you are asking the same thing there. – Wesley Smith Apr 28 '15 at 11:14

0 Answers0