RE: [PHP-DB] array awry

From: Date: Tue, 27 Feb 2001 16:53:23 +0000
Subject: RE: [PHP-DB] array awry
Groups: php.db 
Request: Send a blank email to php-db+get-6984@lists.php.net to get a copy of this message
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:cal@calevans.com] Sent: Tuesday, February 27, 2001 6:50 AM To: Keith Spiller Cc: php-db@lists.php.net 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:rhopkins@mail.waytech.com.tw] Sent: Monday, February 26, 2001 9:10 PM To: Keith Spiller; mysql@lists.mysql.com Cc: php-db@lists.php.net 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:larentium@gilanet.com] Sent: Monday, February 26, 2001 8:15 PM To: mysql@lists.mysql.com Cc: php-db@lists.php.net 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: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#6984) next »