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
Switch is better when there are more than two choices. It's mostly for code readability and maintainability rather than performance.
As others have pointed out, your examples aren't equivalent, however.