I was unable to get a value from a function. While I was going to print the value, its showing the old value "8". It seems function validateInput() is not working.
$current_val = "8";
function validateInput() {
$db = JFactory::getDbo();
//$search = $this->item->producer;
$query = " SELECT * FROM aua8l_djc2_after_reg_page ";
$db->setQuery($query);
$result = $db->query();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$curr = $row['type'];
global $current_val;
switch ($curr) {
case '1':
$current_val = "youtube";
return $current_val;
//echo $current_val;
//return $GLOBALS['current_val'];
break;
case '2':
$current_val = "rdparty";
//return $GLOBALS['current_val'];
break;
case '3':
$current_val = "thankyou";
//return $GLOBALS['current_val'];
break;
}
}
}
}
echo $current_val;