switch and while

From: Date: Fri, 28 Aug 2009 06:03:57 +0000
Subject: switch and while
Groups: php.db 
Request: Send a blank email to php-db+get-46458@lists.php.net to get a copy of this message
Hello. I want do a SWITCH using data base MySQL. The CASE must be a variable, same the ECHO. My table (CATEGORY) contain ID and NAME I do this (with a WHILE): $sqlCat = "SELECT * FROM categoria"; $resultCat = mysql_query($sqlCat); switch ($selectCategory) { while($array=mysql_fetch_array($resultCat)) { case $row[0]: $categoy = "$row[1]"; break; } } But doesnt works, print an error: Parse error: syntax error, unexpected T_WHILE, expecting T_CASE or T_DEFAULT or '}' in C:\AppServ\www\andademiparte\admin\listado.php on line 118... this line is the WHILE. How can resolve this? thanks +                                                                          _    // Emiliano Boragina _    // Diseño & Comunicación ////////////////// +                                                                          _    // emiliano.boragina@gmail.com  /    // 15 40 58 60 02 /////////////////////////// +                                                                          _

« previous php.db (#46458) next »