Re: FW: [PHP] Creating arrays using results from MySQL query

From: Date: Mon, 18 Mar 2002 19:45:18 +0000
Subject: Re: FW: [PHP] Creating arrays using results from MySQL query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-88999@lists.php.net to get a copy of this message
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 ). For some reason, it seems to be skipping > the first record. I don't know what the status of your code is now. But you're probably doing: // read the first record $employee_2 = mysql_fetch_array($result_2); ... ... ... if ($employee_2){ $emp_login_wkgrp_id = array(); $emp_login_grp_id = array(); $emp_login_role_id = array(); $i = 0; // reading the rest of the records 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++; } Thus your first record is 'lost' (not displayed) -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Why would anyone want to be called "Later"? */

« previous php.general (#88999) next »