Barry wrote:
Now time to go back into an array: $colorarray = explode (" ",
$colorstring);
Next I count how many times particular values show up in an array:
$colorvalues = array_count_values ($colorarray);
*Note: This gives me an array with how many times each value shows
up.
So if the user selects three items in column 1 of the matrix, the
array will
show the key as 1 and the value as 3.
Next I count how many questions have been answered: $colorcount = count
($colorarray);
With $colorcount and $colorvalue I can then do the following to give the
appropriate error message:
if ($colorvalues17[1] == '')
{ echo "This is not a problem.";}
else{
if ($colorvalues[1] >1)
{echo "You have too many colors ranked first (column 1).
Please change your answers so you only have one item in the first
column.";}
}
if ($colorvalues17[2] == '') { echo "This is not a problem.";}
else{
if ($colorvalues[2] >1)
{echo "You have too many colors ranked second (column
2).
Please change your answers so you only have one item in the second
column.";}
}
1. There is also called a function elseif()
so you dont have to write
if ()
{
else
{
if () ..code code..;
}
}
just write:
if ()
{
elseif()
{
.. code code ..
}
}
sorry small mistake it has to be:
if ()
{
}
else
{
if () { .. code code ..}
}
just write:
if ()
{
}
elseif ()
{
.. code code ..
}
Greets
Barry
--
Smileys rule (cX.x)C --o(^_^o)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php