Hi Guys,
I've been experiencing some problems when trying to build 3 arrays with the
ID values of all of the groups a user belongs to. (I then want to register
these arrays into the current session). The arrays only appear to be
getting the first value (group ID) instead of all of the values
You have to call mysql_fetch_array for each record in your result set...
$emp_login_wkgrp_id = array ();
$emp_login_grp_id = array ();
$emp_login_role_id = array ();
$i = 0;
while($employee_2 = mysql_fetch_array($result_2)){
$emp_login_wkgrp_id[$i] = $employee_2[wkgrp_id];
[SMTP:[EMAIL PROTECTED]]
Sent: Monday, March 18, 2002 1:26 PM
To: Mullin, Reginald
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Creating arrays using results from MySQL query
You have to call mysql_fetch_array for each record in your result set...
$emp_login_wkgrp_id = array
.
O From Now 'Till Then,
\-Reginald Alex Mullin
/\ 212-894-1690
-Original Message-
From: Mullin, Reginald
Sent: Monday, March 18, 2002 2:29 PM
To: 'Mark Heintz PHP Mailing Lists'; [EMAIL PROTECTED]
Subject: RE: [PHP] Creating arrays using results from MySQL query
On Tuesday 19 March 2002 03:44, Mullin, Reginald wrote:
I've just added another record to the table. Now they're a total of 3
records matching the WHERE emp_id='$emp_login_id criteria. When I
print_r(array_values($emp_login_grp_id)); I get the following values:
Array ( [0] = 222 [1] = 333
-
From: Mullin, Reginald
Sent: Monday, March 18, 2002 2:45 PM
To: '[EMAIL PROTECTED]'
Subject: FW: [PHP] Creating arrays using results from MySQL query
I've just added another record to the table. Now they're a total of 3
records matching the WHERE emp_id='$emp_login_id criteria
I should have been more exact in my original reply. The second query
isn't necessary. Try this:
File: login.php
# if $employee_1, query db workgroups table to check if $emp_login_id
belongs to any groups
$sql_2 = SELECT * FROM workgroups WHERE emp_id='$emp_login_id';
$result_2 =
7 matches
Mail list logo