How can you use switch statements in PHP to display different values based on database results?

When retrieving data from a database in PHP, you may want to display different values based on the results. One way to achieve this is by using switch statements. You can check the database result and use a switch statement to display different values based on different cases. This allows for a more structured and readable way to handle different scenarios.

// Assuming $result is the database result
switch ($result) {
    case 'value1':
        echo 'Display Value 1';
        break;
    case 'value2':
        echo 'Display Value 2';
        break;
    case 'value3':
        echo 'Display Value 3';
        break;
    default:
        echo 'Default Value';
}