tags:

views:

3533

answers:

5

Hello,

I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page.

I would like to know how to synchronize queries between both php files. So when I click on a row in the base page, the layer will be expanded to include additional information, or indeed the whole query.

I was thinking I could do this by having the primary key in the first query for the table, however I don't want it displayed and was wondering if there was a better approach to this?

A: 
Mischa Kroon
I don't want it displayed because I wish it to be a part of the information that is displayed from ajax, as a result of clicking on a row.
Joshxtothe4
A: 

The best and easiest way to handle this would be the following:

  1. USE A FRAMEWORK for your Ajax handling. It will make your life easier and they take care of a lot of stuff that generally you don't need to worry about like how to handle the XMLHttpRequest object across browsers and stuff.
  2. When you load the first table, create a second tr for each tr that displays but make it hidden. You'll populate this second table row with the information from the ajax request.
  3. Modify your ajax function to take the primary key as a parameter. Pass this parameter via either GET or POST to your second php script. You can look here for further clarification on that issue.
  4. Specify the id of the second, hidden tr as the div to update with the response from your ajax request.
Noah Goodrich
+1  A: 

You can do in following way

  1. There should be a hidden textbox in each row of table which will hold the promary key.
  2. when you click the row it will call the javascript function and will pass the id through this like Text. 3.when the user clikc the row it will call the Callfunction in javascript and it will furthur call the ajax and passing the paramanter using GET ot POST method
Raj Kumar
A: 
A: