Re: Validating Radio Buttons in two directions
| From: | Barry | Date: | Thu, 02 Feb 2006 09:21:58 +0000 |
| Subject: | Re: Validating Radio Buttons in two directions | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229700@lists.php.net to get a copy of this message | ||
Barry wrote:
if () { } else {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] == '')1. There is also called a function elseif() so you dont have to write if () {{ 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.";}}else { if () ..code code..; }} just write: if () {elseif() { .. code code .. }} sorry small mistake it has to be:
if () { .. code code ..}
}
just write:
if ()
{
}
elseif ()
{
.. code code ..} Greets Barry -- Smileys rule (cX.x)C --o(^_^o)