Im having problems with a foreach function. The following code results in the error message "Invalid argument supplied for foreach().." is this something to do with my use of $_REQUEST?
<?php
if (isset($_POST['submit'])) {
$answer = array();
$answer[1] = $_REQUEST['improvement'];
$answer[2] = $_REQUEST['planning'];
$answer[3] = $_REQUEST['confidence'];
$answer[4] = $_REQUEST['motivation'];
$answer[5] = $_REQUEST['resources'];
$answer[6] = $_REQUEST['integration'];
$answer[7] = $_REQUEST['diagnosis'];
$answer[8] = $_REQUEST['change'];
$answer[9] = $_REQUEST['expectations'];
$answer[10] = $_REQUEST['validated'];
$answer[11] = $_REQUEST['time'];
$answer[12] = $_REQUEST['demand'];
$answer[13] = $_REQUEST['external_support'];
$answer[14] = $_REQUEST['training'];
$answer[15] = $_REQUEST['depth'];
$answer[16] = $_REQUEST['part'];
$answer[17] = $_REQUEST['cost'];
function pqasso($answer)
{
foreach($answer as $key=>$value)
{
if($value >= "3")
{
$score = $score + 1000;
}
else
{
$score = $score - 1000;
}
}
return $score;
}
function iso($answer)
{
foreach($answer as $key=>$value)
{
if($value >= "3")
{
$score = $score + 1000;
}
else
{
$score = $score - 1000;
}
}
return $score;
}
function iip($answer)
{
foreach($answer as $key=>$value)
{
if($value >= "3")
{
$score = $score + 1000;
}
else
{
$score = $score - 1000;
}
}
return $score;
}
///// feedback for each score
echo "Look at the scores for each quality system below. The higher the score is the more relevant and suited that quality system is to your organisation";
//call the functions and echo them:
if (pqasso($score)>=1000) { print "From your response It looks like PQASSO is an option for you<br>"; }
else { print "PQASSO may not be an appropriate system for you"; }
if (iso($score)>=1000) { print "From your response It looks like ISO is an option for you<br>"; }
else { print "IIP may not be an appropriate system for you"; }
if (iip($score)>=1000) { print "From your response It looks like IIP is an option for you<br>"; }
else { print "IIP may not be an appropriate system for you"; }
}
?>
Im also trying to echo the score for each function too. Instead of:
if (iso($score)>=1000) { print "From your response It looks like ISO is an option for you<br>"; }
else { print "IIP may not be an appropriate system for you"; }
I would like to just echo the score for iip($score). Im not sure what syntax to use after looking at the manual
thx in advance guys