trying to create a global function to auto update value from another table. How do I pass the value of foreign key from current record being inserted/edited. The code below picks up the value correctly if value is from within function. No help available for Currentpage(), $this->$rsnew["xxx"]; doesn't work.
Code below.....
function get_cals(){
$idnut = $rsnew["idnuts"]; //not working
//this works $idnut= 8;
function getCalVal($idnut){
$linker = @mysqli_connect("localhost", "root", "root", "nuts");
if (!$linker) {
die('Connect Error: ' . mysqli_connect_error());
}
$query = "SELECT Calories FROM nut_val WHERE id = " . $idnut or die("Error in the consult.." . mysqli_error($link));
$resultx = $linker->query($query);
$rowx = mysqli_fetch_array($resultx);
$result = $rowx["Calories"];
return $result;
}
$result = getCalval($idnut);
return $result;
}