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: 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]

Reply via email to