CostCare
CostCare

Reputation: 215

more then 1 query per PHP document

For a webpage im using data from mysql to display in charts etc.

For each query that gives me data from mysql i have a seperate php document. is it possible to store more then one query in a php doc instead of creating a new php for every query?

If so, how do i change this getJSON request (because as it is now it uses the whole php doc instead of the specific query i want to use)

department = $("#department").val();
            hospital = $("#hospital").val();

            //console.log('changed'); 
            $.getJSON('functions/charts_hospital.php', {
                "hosp":hospital,
                "dept":department},

I want to use the department and hospital variable in different queries within 1 php document..

Thnaks in advance,

Bart

Upvotes: 1

Views: 38

Answers (1)

CostCare
CostCare

Reputation: 215

For now I found a solution:

Within the getJSON() I put another variable called functionName I use this variable to determine which function should be called from the PHP file. Within these functions is use my other variables. Each function returns the desired data.

All the functions are within one PHP file. So that saves me a lot of other PHP files.

Upvotes: 0

Related Questions