Calling a multidimensional Array

I want to creat a selected grid based on project_name that belongs to login_ID of user. The project_name comes from another table, each project_name can appear more then once. How can I do a select of grid based on the current grid?

MySQL:

login
-login_ID
-user
-password
-role
-title
-lastname
-firstname
-landline
-mobile
-email

mapping_login_project
-mapping_ID
-login_ID
-project_ID

plan
-plan_ID
-date
-author
-project_name
-download_description
-download

project
-project_ID
-project_name

Grid->SQL

SELECT
project.project_name,
login.user,
login.role,
login.title,
login.lastname,
login.firstname,
login.landline,
login.mobile,
login.email
FROM
login,
project,
mapping_login_project
WHERE
mapping_login_project.login_ID=login.login_ID AND
mapping_login_project.project_ID=project.project_ID

Events->OnInit

sc_lookup(get_mapping, “SELECT DISTINCT project.project_name FROM project,mapping_login_project,login,plan WHERE user = ‘[param2]’ AND login.login_ID = mapping_login_project.login_ID AND mapping_login_project.project_ID = project.project_ID”);
sc_lookup(get_table, “SELECT
project.project_name,
login.user,
login.role,
login.title,
login.lastname,
login.firstname,
login.landline,
login.mobile,
login.email
FROM
login,
project,
mapping_login_project
WHERE
mapping_login_project.login_ID=login.login_ID AND
mapping_login_project.project_ID=project.project_ID”);

print_r ({get_table}); // I get all entries of Array {get_table}

// firstfor -> is the max number of register you can do a count in table
// secondfor -> is the max number of fields selected

$result = count({get_table});
echo ($result); // I get number 13 what is right
for($i = 0; $i < count({get_table})-1 ; $i++){
for($j=0; $j < 1 ; $j++){
{get_table[$i][$j]};
}
}
print_r ({get_table[$i][0]}); // I get only one project_name, but there should be 13
echo count({get_table[$i][0]}); // I get number 1

if
(empty({get_mapping}))
{
echo “<script> alert(‘Sie sind aktuell auf kein Projekt gebucht! Bitte wenden Sie sich an einen Administrator’); </script>”;
sc_redir(menu);
}

else
{
echo “<script> alert(‘Projekte die Ihnen zugeordnet sind wurden ausgew?hlt’); </script>”;
$werte_gesamt = “”;
foreach({get_mapping} as $werte_a1)
{
foreach($werte_a1 as $werte_a2)
{
$werte_gesamt .= “’”.$werte_a2."’,";
}
}
sc_select_where(add) = “where ??? IN (”.substr($werte_gesamt, 0, strlen($werte_gesamt)-1).")";
}

get_mapping and get_table work, but I can’t get those two Arrays to match in my last line where I have the sc_select_where(add). print_r ({get_table[$i][0]}); returns only 1 (the last) project_name and not all project_name from my selected grid.

Sorry, but so far I can’t solve it myself even though I’ve been working on this little problem for days. Greetings from Germany

Re: Calling a multidimensional Array

Hi there, I made it but it is still not working. I get Error:

FUNCTION project.project_IDwhere does not exist
select count(*) from login, project, mapping_login_project where mapping_login_project.login_ID=login.login_ID AND mapping_login_project.project_ID=project.project_IDwhere ('asv','asv','asv','asv','bbsv','bbsv','bbsv','sepo','sepo','sepo','lcpb','lcpb') IN ('asv')

This is my code:

//All project_name of user that is logged in are put in get_mapping
sc_lookup(get_mapping, "SELECT DISTINCT
  project.project_name
FROM
  project,
  mapping_login_project,
  login,plan
WHERE
  user = '[param2]' AND
  login.login_ID = mapping_login_project.login_ID AND
  mapping_login_project.project_ID = project.project_ID");
  
//All project.project_name mapped on login.login_ID are put in get_table 
sc_lookup(get_table, "SELECT
  project.project_name,
  login.user,
  login.role,
  login.title,
  login.lastname,
  login.firstname,
  login.landline,
  login.mobile,
  login.email,
  project.project_ID
FROM
  login,
  project,
  mapping_login_project
WHERE
  mapping_login_project.login_ID=login.login_ID AND
  mapping_login_project.project_ID=project.project_ID");

//Current Grid ist put in an Array, column with all project_name is put in $project_name
// firstfor -> is the max number of register you can do a count in table
// secondfor -> is the max number of fields selected

$result = count({get_table});
echo ($result);
$project_name = "";
for($i = 0; $i < count({get_table})-1 ; $i++){
for($j=0; $j < 1 ; $j++){
$project_name .= "'".{get_table[$i][$j]}."',";
}
} 
print_r ($project_name);



if
(empty({get_mapping}))
{
echo "<script> alert('Sie sind aktuell auf kein Projekt gebucht! Bitte wenden Sie sich an einen Administrator'); </script>";
sc_redir(menu);
}

else
{
echo "<script> alert('Projekte die Ihnen zugeordnet sind wurden ausgew?hlt'); </script>";
$werte_gesamt = "";
foreach({get_mapping} as $werte_a1)
{
foreach($werte_a1 as $werte_a2)
{
$werte_gesamt .= "'".$werte_a2."',";
}
}
sc_select_where(add) = "where (".substr($project_name, 0, strlen($project_name)-1).") IN (".substr($werte_gesamt, 0, strlen($werte_gesamt)-1).")";
}

Re: Calling a multidimensional Array

This Code seems to do what I want, but I get Error…how can I call column project.project_name that comes from my first SELECT?

Operand should contain 13 column(s)
select count(*) from login, project, mapping_login_project where mapping_login_project.login_ID=login.login_ID AND mapping_login_project.project_ID=project.project_ID AND ('asv','asv','asv','asv','bbsv','bbsv','bbsv','sepo','sepo','sepo','lcpb') IN ('asv')

Code onInit

//All project_name of user that is logged in are put in get_mapping
sc_lookup(get_mapping, "SELECT DISTINCT
  project.project_name
FROM
  project,
  mapping_login_project,
  login,plan
WHERE
  user = '[param2]' AND
  login.login_ID = mapping_login_project.login_ID AND
  mapping_login_project.project_ID = project.project_ID");
  
//All project.project_name mapped on login.login_ID are put in get_table 
sc_lookup(get_table, "SELECT
  project.project_name,
  login.user,
  login.role,
  login.title,
  login.lastname,
  login.firstname,
  login.landline,
  login.mobile,
  login.email,
  project.project_ID
FROM
  login,
  project,
  mapping_login_project
WHERE
  mapping_login_project.login_ID=login.login_ID AND
  mapping_login_project.project_ID=project.project_ID");

//Current Grid ist put in an Array, column with all project_name is put in $project_name
// firstfor -> is the max number of register you can do a count in table
// secondfor -> is the max number of fields selected

$result = count({get_table});
echo ($result);
$project_name = "";
for($i = 0; $i < count({get_table}) ; $i++){
 for($j=0; $j < 1 ; $j++){
  $project_name .= "'".{get_table[$i][$j]}."',";
 }
} 
print_r ($project_name);



if (empty({get_mapping})){
 echo "<script> alert('Sie sind aktuell auf kein Projekt gebucht! Bitte wenden Sie sich an einen Administrator'); </script>";
 sc_redir(menu);
}

else{
 echo "<script> alert('Projekte die Ihnen zugeordnet sind wurden ausgew?hlt'); </script>";
 $werte_gesamt = "";
 foreach({get_mapping} as $werte_a1){
  foreach($werte_a1 as $werte_a2){
   $werte_gesamt .= "'".$werte_a2."',";
  }
 }
sc_select_where(add) = " AND (".substr($project_name, 0, strlen($project_name)-1).") IN (".substr($werte_gesamt, 0, strlen($werte_gesamt)-1).")";
} 

Re: Calling a multidimensional Array

I solved it…I needed to JOIN my two tables login and project in the first SELECT statement in order to use the project.project_name column that was created using my third table mapping_login_project

SELECT
  project.project_name,
  login.user,
  login.role,
  login.title,
  login.lastname,
  login.firstname,
  login.landline,
  login.mobile,
  login.email
FROM
  login JOIN
  project,
  mapping_login_project
WHERE
  mapping_login_project.login_ID=login.login_ID AND
  mapping_login_project.project_ID=project.project_ID

Now I can add

sc_select_where(add) = " AND project.project_name IN (".substr($werte_gesamt, 0, strlen($werte_gesamt)-1).")";