dflow Posted December 20, 2009 Share Posted December 20, 2009 how do i echo inside the switches? $CatgeoryID=$row_RsProductInfo['CategoryID']; switch ($CatgeoryID) { case 1: echo" <a href="index.php" class="product-title"> <?php echo $row_RsCity['CityName']; ?> <?php echo $row_RsProductInfo['UnitPrice']; ?><?php echo $row_RsCurrencies['Symbol']; ?> </a>"; break; case 1: echo" <a href="index.php" class="product-title"> <?php echo $row_RsCity['CityName']; ?> <?php echo $row_RsProductInfo['UnitPrice']; ?><?php echo $row_RsCurrencies['Symbol']; ?> </a>"; break; } Link to comment https://forums.phpfreaks.com/topic/185785-help-with-syntax/ Share on other sites More sharing options...
Buddski Posted December 20, 2009 Share Posted December 20, 2009 Here is an example of a switch switch ($test) { case 'hello': echo $test . ' says Hello'; break; } if $test == 'hello' the output will be: "hello says Hello" You dont need all those extra <?php and echo statements. Link to comment https://forums.phpfreaks.com/topic/185785-help-with-syntax/#findComment-980994 Share on other sites More sharing options...
dflow Posted December 20, 2009 Author Share Posted December 20, 2009 thanks Link to comment https://forums.phpfreaks.com/topic/185785-help-with-syntax/#findComment-981015 Share on other sites More sharing options...
dflow Posted December 20, 2009 Author Share Posted December 20, 2009 how would you add html like <div><a href="blah"></a><div> into the cases? Link to comment https://forums.phpfreaks.com/topic/185785-help-with-syntax/#findComment-981044 Share on other sites More sharing options...
Buddski Posted December 20, 2009 Share Posted December 20, 2009 Same as everything else switch ($test) { case 'John': echo '<i>'.$test . '</i> says <strong>Hello</strong>'; break; } will output "John says Hello" Link to comment https://forums.phpfreaks.com/topic/185785-help-with-syntax/#findComment-981047 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.