Re: One works, but the other doesn't
| From: | chris smith | Date: | Tue, 23 May 2006 12:23:12 +0000 |
| Subject: | Re: One works, but the other doesn't | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-236712@lists.php.net to get a copy of this message | ||
On 5/23/06, Jonas Rosling <webmaster@gamearena.se> wrote:
-----Ursprungligt meddelande----- Från: chris smith [mailto:dmagick@gmail.com] Skickat: den 23 maj 2006 14:13 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling <webmaster@gamearena.se> wrote: -----Ursprungligt meddelande----- Från: chris smith [mailto:dmagick@gmail.com] Skickat: den 23 maj 2006 13:38 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling <webmaster@gamearena.se> wrote:Look at it this way - Which one is easier to read? Which one do you think will be easier to work out what's going wrong? Readability of your code will help you so much. If you come back to this in a week, will you understand what's going on? I don't know if my code will give you *exactly* what you want - test it and see (backup your existing php file, change this code, see what you get). -- Postgresql & php tutorials http://www.designmagick.com/I find this problem very strange. I've got two parts of code (allmostthesame) in different TD's with vars and arrays (with same name) but it'sonlythe top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like:Without seeing the whole code involved, my guess is you're resetting the array with every loop. Guesses don't help but that's all we can do without seeing any actual code. Okej, all the code follows bellow. Remember that part 1 allways works. And they work all seperatly. Man you do things the hard way. Why use all those variable variables? $my_data = array(); // Loppar igenom raderna while($row=mysql_fetch_assoc($result)) {${$row[0]} = array();${$row[0]}[$row[1]] = $row[2];But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one?$code = $row['salesperson_code'];if (!isset($my_data[$code])) { $my_data[$code] = array( 'description' => $row['description'], 'total' => $row['totalt'], 'antal' => $row['antal'] ); } else { $my_data[$code]['description'] = $row['description']; }} ------------------------- Well, I'm kind of a newbie at this. So you think this will solve my problem?