Creating arrays using results from MySQL query
| From: | Mullin, Reginald | Date: | Mon, 18 Mar 2002 18:12:49 +0000 |
| Subject: | Creating arrays using results from MySQL query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-88975@lists.php.net to get a copy of this message | ||
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 the user
belongs to. What am I doing wrong here?
My code looks like 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 = @mysql_query($sql_2) or die (mysql_error());
$rows = mysql_num_rows($result_2);
$employee_2 = mysql_fetch_array($result_2);
# if match, set workgroups login variables in array, then register
workgroups login variables in session
if ($employee_2){
$emp_login_wkgrp_id = array ();
$emp_login_grp_id = array ();
$emp_login_role_id = array ();
for ($i=0; $i<$rows; $i++){
$emp_login_wkgrp_id[$i] = $employee_2["wkgrp_id"];
$emp_login_grp_id[$i] = $employee_2["grp_id"];
$emp_login_role_id[$i] = $employee_2["role_id"];
}
session_register('emp_login_wkgrp_id');
session_register('emp_login_grp_id');
session_register('emp_login_role_id');
}
O From Now 'Till Then,
\-> Reginald Alex Mullin
/\ 212-894-1690
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the postmaster at postmaster@sothebys.com.
www.sothebys.com
**********************************************************************