Re: [PHP-DB] array awry

2001-02-27 Thread CC Zona

In article 061201c0a063$08eab5a0$[EMAIL PROTECTED],
 [EMAIL PROTECTED] ("Keith Spiller") wrote:

 This associative array embedded within a function and declared as a global at 
 the start of the function, is meant to be a multidimensional array, but with 
 every loop of the while ($myrow = mysql fetch row($result)) statement, it's 
 previous values are replaced by the new ones.  Any ideas on how I can fix 
 this?
 
   If ($Selection == "3")
   {
   $tabledata[catid]= $myrow[0];
   $tabledata[category] = "$myrow[1]";
   $tabledata[under]= $myrow[2];
   $tabledata[corder]   = $myrow[3];
   $tabledata[active]   = $myrow[4];
   }


So what you're saying is that want indexes 'catid', 'category', etc. to 
have a distinct value for each row pulled from the database?  Then you need 
to add another dimension to that array.

-- 
CC

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] array awry

2001-02-27 Thread Rick Emery

All,

Perhaps I've misunderstood.

I thought this IS a PHP list (see Rolf Hopkins below).

Secondly, this list is not only for MySQL questions and issues (see Cal
Evans below).  It is for all database questions, as we've seen from uestins
concerning other databases.

Am I incorrect?

Richard L. Emery
IT Sr. Project Manager

"There is no 'trying'...
There is only 'Do' or 'Not Do' "


-Original Message-
From: Cal Evans [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 27, 2001 6:50 AM
To: Keith Spiller
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] array awry


Hi Keith,

1: Don't cross-post. It's rude. Especially since this has nothing to do with
MySQL.

2: You are not building a multi-dimensional array. The code below won't even
build a single dimensional array because you didn't put your keys in quotes
so it's probably blowing chunks. At the very least, if you had put quotes
around your key names, it would have overwritten the data each loop.

Try something like this:

  If ($Selection == "3")
  {
  $lcvA++;
  $tabledata[$lcvA] = Array();
  $tabledata[$lcvA]['catid']= $myrow[0];
  $tabledata[$lcvA]['category'] = "$myrow[1]";
  $tabledata[$lcvA]['under']= $myrow[2];
  $tabledata[$lcvA]['corder']   = $myrow[3];
  $tabledata[$lcvA]['active']   = $myrow[4];
  }

This is a multidimensional array. The first dimension is a counter, $lcvA.
Make sure you init it at the top of your function.  Now, each time you add a
row to the array, it' in a new row IN the array.

To access the data you use:

$myCOrder = $tabledata[$rowToAccess]['corder']

HTH,
Cal
http://www.calevans.com

-Original Message-
From: Rolf Hopkins [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 26, 2001 9:10 PM
To: Keith Spiller; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: array awry


This is a PHP question and should really be asked on the PHP list.

But a suggestion.  Tried using field names instead of number?  ie.
$myrow["catid"];

I'd have to read up the PHP manual to find out for sure but I'm sure you can
do that just as well as I can.

-Original Message-
From: Keith Spiller [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 26, 2001 8:15 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: [PHP-DB] array awry


This associative array embedded within a function and declared as a global
at the start of the function, is meant to be a multidimensional array, but
with every loop of the while ($myrow = mysql_fetch_row($result)) statement,
it's previous values are replaced by the new ones.  Any ideas on how I can
fix this?

  If ($Selection == "3")
  {
  $tabledata[catid]= $myrow[0];
  $tabledata[category] = "$myrow[1]";
  $tabledata[under]= $myrow[2];
  $tabledata[corder]   = $myrow[3];
  $tabledata[active]   = $myrow[4];
  }

Keith
aka Larentium


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] array awry

2001-02-26 Thread Keith Spiller

This associative array embedded within a function and declared as a global at the 
start of the function, is meant to be a multidimensional array, but with every loop of 
the while ($myrow = mysql_fetch_row($result)) statement, it's previous values are 
replaced by the new ones.  Any ideas on how I can fix this?

  If ($Selection == "3")
  {
  $tabledata[catid]= $myrow[0];
  $tabledata[category] = "$myrow[1]";
  $tabledata[under]= $myrow[2];
  $tabledata[corder]   = $myrow[3];
  $tabledata[active]   = $myrow[4];
  }

Keith
aka Larentium