Re: Function misfunction - 2

From: Date: Tue, 31 Dec 2002 14:12:48 +0000
Subject: Re: Function misfunction - 2
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-129774@lists.php.net to get a copy of this message
so you want $lookuptable=setCurrentDevGroup($devID); switch($lookuptable) { ... Martin S wrote:
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.


« previous php.general (#129774) next »