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 =
Do you understand the options that the other people have explained?
-- Rodney
"Ashley M. Kirchner" wrote:
"Rodney J. Woodruff" wrote:
http://www.php.net/manual/en/function.msql-fetch-array.php
Okay, call me dense. I can't figure this out. This is what I'm trying to
do:
$sql
[posted and emailed]
If you're looking for a simple way to work with databases I would use
phplib. Phplib is a db abstraction layer which supports over a dozen
databases including mysql. You can get the libraries at
http://phplib.netuse.de/download/phplib-7.2c.tar.gz You will need to
use
[posted and emailed]
On 12 Apr 2001 12:48:52 -0700, [EMAIL PROTECTED] (Jeffrey
Greer) wrote:
// putting the values in an array is trivial, but you should do it
like this
// or you will confuse your numeric ids with the ids that php
puts in an array automatically
Whoops. I was wrong about
I need to convert an MySQL result into an Array...somehow. The
query returns the following:
++---+
| ID | Project |
++---+
| 1 | Home |
| 2 | Work |
| 3 | Family |
| 4 |Misc. |
| . | ... |
| . |
http://www.php.net/manual/en/function.msql-fetch-array.php
Hope this helps.
"Ashley M. Kirchner" wrote:
I need to convert an MySQL result into an Array...somehow. The
query returns the following:
++---+
| ID | Project |
++---+
| 1 |
try
?php
while( $my_data = msql_fetch_row ( $your_query_identifier ){
$the_array_I_want[ $my_data[ 0 ] ] = $my_data[ 1 ] ;
}
echo "PRE";
print_r( $the_array_I_want );
echo "/PRE";
?
Be aware that adding an element to
"Rodney J. Woodruff" wrote:
http://www.php.net/manual/en/function.msql-fetch-array.php
Okay, call me dense. I can't figure this out. This is what I'm trying to
do:
$sql = "select p_id, project from proj where uid=$uid";
$result = mysql_db_query($database,$sql);
(the
On Wed, Apr 11, 2001 at 03:55:38PM -0600, Ashley M. Kirchner wrote:
"Rodney J. Woodruff" wrote:
http://www.php.net/manual/en/function.msql-fetch-array.php
(snip)
I need that result into the following:
$items = array(0 = "Undefined", 1 = "Work", 2 = "Personal");
Here's a hint.
15 matches
Mail list logo