> -----Original Message-----
> From: Martin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 02, 2001 10:48 AM
> To: Mark Roedel; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] array_diff usage
> 
> 
> 
>> This, on the other hand, makes me suspect that the arrays themselves
>> don't actually contain what you think they do.  How are you 
>> assigning the values you described at the top of your message?
> 
> I get them from a database by two select queries.
> Then I do
> 
> $noOpened=mysql_num_rows($jobresult1);
>         $noClosed=mysql_num_rows($jobresult2);
>         $getlargest = strcmp($noOpened, $noClosed);
> 
>         switch ($getlargest) {
>               case $getlargest > 0:
>             $counttickets = $noOpened;
>                 while($sumOpen=mysql_fetch_row($jobresult1)) {   
>                  $Open = $sumOpen;
>                  // DEBUG
>                  print $Open[0] . "<br>";
>                 
>                }
>                while($sumClosed=mysql_fetch_row($jobresult2)) {   
>                  $Closed = $sumClosed;
>                  // DEBUG
>                  print "c" . $Closed[0] . "<br>";
>                
>                }
> 
> Which produces:
> 1
> 2
> 3
> 4
> 5
> c1
> c2
> 
> So the arrays are correctly set up (I think).

Actually, no.  It looks to me as if each only contains, at any given
time, the most recent value you assigned.  (That is, $Open[0] only
contains the value "5" at the end of the run, and $Closed[0] only
contains the value "2".)

That, in fact, explains the results of your array_diff() quite nicely.

For what you apparently really mean to do, you'll want to replace
        $Open = $sumOpen;

with something that looks more like
        $Open[] = $sumOpen;

(That'll append the value of $sumOpen to the end of the $Open array,
rather than overwriting the entire $Open variable with the value of
$sumOpen.

Make sense?


---
Mark Roedel ([EMAIL PROTECTED])  ||  "There cannot be a crisis next week.
Systems Programmer / WebMaster  ||   My schedule is already full."
     LeTourneau University      ||                    -- Henry Kissinger


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