switch()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have something like this:

<?php
$query = mysql_query("
		SELECT col_1, col_2
		FROM table
	");
$result = mysql_fetch_array($query);
if ($result['col_1'] == 'value_1')
{
	// do something
}

if ($result['col_2'] == 'value_2')
{
	// do something
}
?>

when I tried to use swiitch()
<?php
switch (true)
{
	case ($result['col_1'] == 'value_1'):
		// do something
		break;

	case ($result['col_2'] == 'value_2'):
		// do something
		break;
}
?>

it will give me only the first true case. if $result['col_1'] == 'value_1'
is true 2nd case will never be executed?
Does it mean I CANNOT use switch() in this case?

-afan

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux