So, you know, the problem with your if / else is that the latter always happens. The switch is still better, but here is what your code should do:
if ($_POST['sizes'] == "Small ($30)") { $total = "30"; } else if ($_POST['sizes'] == "Medium ($40)") { $total = "40"; } else if ($_POST['sizes'] == "Large ($50)") { $total = "50"; } else { $total = $_POST['price']; }
For everyone who says that the problem is $ 30, $ 40, etc., it is not. Variables cannot start with a number, so PHP ignores $ 40, etc.
source share