/** * Gets the user name by the ID * * @param int $ID */ function displayUserNameByID($ID) { // the name to return $name = ""; // include the lookup object include_once "UserLU.php"; // get a lookup object $userlu = new UserLU(); // get the items for the pull down $retval = $userlu->getAllUserNames(); // success? if ($retval == 0) { // get the items in the list $items = $userlu->getUserNameList(); // for each item returned foreach ($items as $item) { // is this the ID we are looking for if ($item[0] == $ID) { // save the output $name = $item[3] . ' ' . $item[4]; // no need to continue break; } } } // return to the caller return $name; }
$retval = $lus->getLookupByName($itemName); // success? if ($retval == 0) { $arr = $lus->getLookupList(); foreach ($arr as $item) { echo "Name:" . $item->Name . ", ID:" . $item->ID . "\n"; } } echo "\n Now by name by ID \n"; $retval = $lus->getItemNameByID(1); echo "ID: 1, name:" . $retval . "\n"; echo "\n Get the user names\n"; include_once "UserLU.php"; $userlu = new UserLU(); $retval = $userlu->getAllUserNames(); // success? if ($retval == 0) { $arr = $userlu->getUserNameList(); foreach ($arr as $item) { echo "Name:" . $item[0] . "\n"; } } echo "\n Get the user ID/Roles\n"; $retval = $userlu->getUserIDRoles("Phil Owen"); // success? if ($retval == 0) { $arr = $userlu->getUserIDRoleList(); foreach ($arr as $item) { echo "Name: Phil Owen, ID: " . $item[0] . ", Role: " . $item[1] . "\n"; } }