RE: [PHP] Creating arrays using results from MySQL query
| From: | Mark Heintz PHP Mailing Lists | Date: | Mon, 18 Mar 2002 20:06:30 +0000 |
| Subject: | RE: [PHP] Creating arrays using results from MySQL query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-89004@lists.php.net to get a copy of this message | ||
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 = @mysql_query($sql_2) or die (mysql_error());
# initialize empty arrays
$emp_login_wkgrp_id = array();
$emp_login_grp_id = array();
$emp_login_role_id = array();
$i=0;
# while there are matches, set workgroups login variables in array, then
# register workgroups login variables in session
while($employee_2 = mysql_fetch_array($result_2)){
$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"];
$i++;
}
session_register('emp_login_wkgrp_id');
session_register('emp_login_grp_id');
session_register('emp_login_role_id');
mh