I am trying to replicate an app in Angular Material that I have had running for a couple years with HTTP/JavaScript etc. The app is what could be called a database type app with CRUD operations on a MySQL database on a remote server which uses PHP between the App and the Database.
Several of the tables which are returned from the server in JSON are range limited by a parameter sent from the JavaScript, and then received by the PHP, and used in the where clause of the Select statement like this code snippet:
$registration = $_POST['REGISTRATION'] ;
$query = "SELECT sysid, REGISTRATION, TYPE, COMPONENT, SERIAL, PART_NUMBER FROM status_hours WHERE REGISTRATION='$registration' ";
This HTTP/JavaScript/PHP code is working perfectly, however I would like to replicate the app in Angular Material.
With Angular Material I can retrieve recors in JSON perfectly, but the problem is that I can not send a parameter and get it working so that it can be used in the WHERE clause in the PHP.
Here is the Type Script code on the app which gets a table of rows from the server.
const url = 'http://mydatabase.com/angular/php/status_hours.php' ;
const options = { params: new HttpParams().set('REGISTRATION', this.REGISTRATION) } ;
this.http.get<Hours[]> (url, options)
.subscribe(hours =>
{
console.log(hours) ;
this.dataSource.data = hours ;
} ) ;
Here is the PHP code I have tried, to receive the parameter which is called REGISTRATION so that it can be used in the WHERE statement.
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$registration = $request->REGISTRATION;
The problem is either the parameter is not being sent by the Angular app, or it is not being received by the PHP so that it can be used in the WHERE clause.
I can hardcode for sumulation purposes, $registration = 'hardCodedData' ; and it will return valid JSON data.
Thank-you for your assistance.