I am trying to create a function that gets the name and clientid. What is the proper way to return an array? so that I can have multiple values returned.
function get_client_name($conn, $clientid){
$response = array();
$query = "SELECT NAME, CLIENTID FROM LCCLIENT WHERE CLIENTID = '". $clientid ."'";
$sql = oci_parse($conn, $query);
$exec = oci_execute($sql);
if($exec){
$row = oci_fetch_array($sql);
$response[] = array(
'CLIENTID' => trim($row['CLIENTID']),
'NAME' => trim($row['NAME'])
);
}
return json_encode($response);
}
echo get_client_name($conn, '2000000800')[0]['CLIENTID'];
echo get_client_name($conn, '2000000800')[0]['NAME'];
return $responseCLIENTID, you already know it. You also may be open to SQL injections. Best to parameterize.