I\'m in a dilemma. Which is best to use and why.. switch or if?
switch ($x)
{
case 1:
//mysql query
//echo something
break;
case 2:
//mysql query
both of the statement are decision making statement by comparing some sort of the parameters and then show the results. the switch statement is no doubt faster than the if statement but the if statement has a bigger advantage over the switch statement that is when you have to use logical operations like (<,>,<=,>=,!=,==). whenever you came across with the logical operations you will be struck off by using switch statement but don't worry there is another way which can be use to reach at your goal that is if-statement or if-else or if-else-if statement. I'll suggest you to use if-else most of the time rather than the switch one.