I'm using Wordpress with JQuery to produce a vehicle selection form.

Vehicle details are retrieved by JQuery Ajax calls to some PHP after sales script. The PHP scripts query an SQLite database for vehicle information.

Wordpress form -> JQuery get -> PHP script -> SQLite DB

I've three distinct queries that should be performed:

  1. Vehicle provides
  2. Vehicle models for any specific vehicle make
  3. Vehicle years for any specific vehicle brand name

I possibly could produce a custom PHP script that accepts a "query_type" parameter in the JQuery get call. The PHP script would then run the right SQL query. That option sounds mediocre at best.

Must I produce a custom PHP apply for each one of the three queries?


It is possible to neat PHP tool and build something such as .NET's Service Endpoints?

The Service Interface Pattern

Thanks Everybody!

Use JQuery to publish the "type" of query you need to get. You need to just have one PHP script, just allow the PHP determine which kind of information is being asked for.

You might like to consider coming back JSON data as it is simpler to cope with using JQuery: JQuery Docs - getJSON

So far as getting PHP to know what's being asked for, make use of a query string inside your URL: request.php?r=make, or request.php?m=datsun&r=model, or request.php?ma=datsun&mo=280zx&r=year

Then in PHP:

  case "make":
    //return request for makes here
  case "model":
    //return request for model here, checking for existence of make request and validity
  case "years":
    //return request for vehicle years, based on existence of other two variables.