RE: [PHP] Control Structure Problem

From: Date: Sun, 22 Jul 2001 17:21:18 +0000
Subject: RE: [PHP] Control Structure Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59074@lists.php.net to get a copy of this message
I forgot to say I deleted tabs so that the width might fit in a typical mail reader. Jeff Oien > 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++; > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#59074) next »