Jason Wong wrote:

> On Tuesday 31 December 2002 20:48, Martin S wrote:
> 
>> This is the function which should return e.g. "printers" for
>> $lookuptable. But doesn't.
>>
>> function setCurrentDevGroup($devID)
>>         {
>>                 global $adb;
>>         $query = "SELECT dev_group FROM tracking WHERE (computer =
>> $devID)"; $sth = $adb->prepare($query);
>>                 if($sth)
>>                 {
>>                         $res = $sth->execute();
>>                         $resulttable = $sth->fetchrow_hash();
>>                         $lookuptable = $resulttable["dev_group"];
>>                         // DEBUG
>>                         echo $lookuptable; // this give the correct value
> 
> So here $lookuptable contains the correct value (eg "printers") ??

Correct. At this point $lookuptable contains the value of dev_group.

> 
>>                 }
>>                 return $lookuptable;
>>         }
> 
> But something like:
> 
>   echo setCurrentDevGroup($devID);

That gives the correct value as well. But I wanted it as a variable 
($lookuptable) ...

What I am trying to do is:

setCurrentDevGroup($this->Computer); // call function and get a device group
switch ($lookuptable) {
        case "computers":
                bla bla bla
        case "printers":
                yada yada yada
        }

However, getting the inspired moment from your post, I tried

switch (setCurrentDevGroup($this->Computer)) {
        case "computers":
                bla bla bla
        case "printers":
                yada yada yada
        }

And now this part works at least.
My understanding was that the function would return a value for $lookuptable 
which was useable in the code above. This is incorrect then? 

/Martin S.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to