Hi - I'm a TOTAL php NEWBIE - my 1st bit of code!!!.

Basically the input form page has 17 sets of radio buttons, each
representing one game with 2 options - team 1 and team 2. What I want to do
is a better way of checking each radio button value instead of using an if
statement for each. This code doesn't really work - it finds that vars
ALWAYS exist.

IE:

<INPUT NAME=Game1 VALUE=1>Chicago
<INPUT NAME=Game1 VALUE=2>whatever

<INPUT NAME=Game2 VALUE=3>Minny
<INPUT NAME=Game2 VALUE=1>Nobody

Code above is processed by the following code:

for ($GameIdx = 1; $GameIdx <= 17; $GameIdx++) {
 /* instead "hardcoding each radio button name - just do it programmatically
by concatenating / creating the name */
 $frmGame = "Game" + $GameIdx;
 if ($frmGame) {
  /* U want to check if the length is 5 or 6 bytes because it could be
"game1" or "game14" */
  $Length = strlen($frmGame);
  if ($Length == 5) {
   $GetNumber = 1;
  }
  else {
   $GetNumber = 2;
  }

  $GameID = intval(substr($frmGame, $Length - $GetNumber, $GetNumber));
  print "Game ---> $GameIdx - $frmGame - $GetNumber - $GameID <BR>";
    if ($GameID == $GameIdx) {
   print "Yeah Match - $GameID = $GameIdx <BR>";
   /* OK, here is where U want to do the actual insert */
  }
 } /* $frmGame endif */
}

?>


Thanks




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to