Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
#827332
Hello everybody,

I have to calculate a specific variable for a user logged according to his groups of membership.

I try to do it with this code but $query1 part seams to doesn't work (if I replace $result1 by a list of group id in $query2, it works as I want).

$reglenommage="RVD_NAT_DA_H66";//namerule
$UserID=@@USER_LOGGED;//user_uid of user logged
$query1= "select distinct GRP_UID from GROUP_USER where USR_UID=$UserID";//groups of user logged
$result1= executeQuery($query1);
$query2= "select distinct GRP_TITLE, GRP_UID from GROUPWF where GRP_TITLE like '$reglenommage%' and GRP_UID in($result1)";//groups matching to namerule within groups of user logged
$result2=executeQuery($query2);
$GroupTitle=$result2[1]['GRP_TITLE'];//first result matching
$region = substr($GroupTitle, 11, 6);//truncate group name
@@INIT_CODE_REGION=$region;

Could you help me, please ?
#827333
Hi,
Your code should be well-written to make it easier for you to understand and troubleshoot.
Please check this code:
Code: Select all
$reglenommage = "RVD_NAT_DA_H66";	//namerule
$UserID = @@USER_LOGGED;			//user_uid of user logged

$query = '
	select distinct GRP_UID
	from GROUP_USER
	where USR_UID = "'.$UserID.'";
';
$result = executeQuery($query);

$temp = [];
foreach($result as $row)
	array_push($temp, $row['GRP_UID']);

if(count($temp) > 0){
	$query = '
		select distinct GRP_TITLE, GRP_UID
		from GROUPWF
		where GRP_TITLE like "'.$reglenommage.'%" and GRP_UID in("'.implode('" , "', $temp).'");
	';
	$result = executeQuery($query);
	if(is_array($result) && count($result) > 0){
		$GroupTitle = $result[1]['GRP_TITLE'];	//first result matching
		$region = substr($GroupTitle, 11, 6);	//truncate group name
		@@INIT_CODE_REGION = $region;
	}
}
https://pmlearning.info
Thanks
Last edited by programerboy on Wed Apr 07, 2021 1:08 am, edited 1 time in total.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]