Control Structure Problem

From: Date: Sun, 22 Jul 2001 17:14:41 +0000
Subject: Control Structure Problem
Groups: php.general 
Request: Send a blank email to php-general+get-59073@lists.php.net to get a copy of this message
This is driving me nuts. I couldn't sleep much last night trying to figure this out. This code assigns rooms to kids signing up for Sunday school at a very large church. Each subsequent registration is put into the next room on the list. It looks up in the MySQL database the room the last person in that age category and hour was assigned and assigns the current person the next one. If someone is the first person they get assigned the first room. However if they are the first person ${"newroom".$x} doesn't get assigned to anything. But thereafter it works fine. I've had a couple other problems and am wondering if there is a better way to do this or if I have any syntax problems. Thanks. Jeff Oien $x = 1; while ($x <= $Number_Children) { if (${"category".$x} == 'SS KidZone - Kindergarten') { if ((${"Grade".$x}) == 'K' && (${"selection".$x}) == '2nd Hour') { $sql = "SELECT * FROM $table_name WHERE Category = 'SS KidZone - Kindergarten' && Element1 = '2nd Hour' ORDER by ID desc"; $result = @mysql_query($sql,$connection) or die("Couldn't execute query"); if ($row = mysql_fetch_array($result)) { $room = $row['Element2']; if ($room == 'C143 Pink Check') { ${"newroom".$x} = 'C143 Pink Dot'; } if ($room == 'C143 Pink Dot') { ${"newroom".$x} = 'C148 Teal Check'; } if ($room == 'C148 Teal Check') { ${"newroom".$x} = 'C148 Teal Dot'; } if ($room == 'C148 Teal Dot') { ${"newroom".$x} = 'C143 Pink Check'; } } else { ${"newroom".$x} = 'C143 Pink Check'; } } "do database insertion" } $x++; }

« previous php.general (#59073) next »