[Solved] My case switch is return me nothing


I woudn’t use an anonymous function here. You can assign the time_limit to the variable directly.

<?PHP
$link       = mysqli_connect("localhost", "root", "", "table");
$q          = mysqli_query($link, "SELECT * FROM sections WHERE id = " . mysqli_real_escape_string($link,$_GET['id'] . " "));
$time_limit = "";
while ($row = mysqli_fetch_assoc($q)) {
    $sections = $row['section'];
    switch ($sections) {
        case "Solo":
            $time_limit = "2:10"; //time limit
            break;
        case "Duo/Trio/Quartet":
            $time_limit = "2:10"; //time limit
            break;
        case "Formation":
            $time_limit = "4:20"; //time limit
            break;
        case "Groups":
            $time_limit = "3:40"; //time limit
            break;
    }
}
echo "Your moment has $time_limit seconds"; // example
?> 

Also: It’s a very bad idea to use user input unsanitised, since your code is vulnerable for SQL-Injection attacks. Therefore I’ve added mysqli_real_escape_string.

6

solved My case switch is return me nothing