If you made an array for your buttons, then you could use PHP's looping constructs to process the array. Write the input tag like this:
<INPUT NAME=Game[1] VALUE=1>Chicago The processing code will then have access to the array $Game indexed by the game number, e.g., $Game[1]. Good luck! Kirk > -----Original Message----- > From: Shew [mailto:[EMAIL PROTECTED]] > Sent: Thursday, August 01, 2002 9:19 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: Dynamically check radio buttons > > > OK, changed the subject to what I think it should be about. > > Anybody? > > "Shew" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php