rest api to get some field

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
lamany77
User
Posts: 144

rest api to get some field

Post by lamany77 »

Dear all i have code below

server event-global-all page-global code :

$API_ACTIONS["getProductByName"] = function(Request $request, Response &$response) {
$name = Param("name", Route(1)); // Get parameter from $GET or $POST
if ($name !== NULL)
WriteJson(ExecuteRow("SELECT * FROM t_dpr WHERE no_pr = '" . AdjustSql($name) . "'"));
};

table spesific-add/copy page - startup script :
$.get("api/?action=getProductByName&name=PR00000001", function(res) { // Get response from API
console.log(res); // Show the result in console
alert(res);

alert(res);

the result is nothing any idea or something wrong with my code.


mobhar
User
Posts: 11737

Post by mobhar »

Change this code:
if ($name !== NULL)

to:
if (!empty($name))


smuyambo
User
Posts: 8

Post by smuyambo »

I am trying to understand how I can specify more than one parameter in the API call. Using the example above say I have name and age

$.get("api/?action=getProductByName&name=PR00000001&age>18", function(res)


Post Reply