使用PHP中的数组根据以前的结果回显值

时间:2018-04-16 23:06:00

标签: php arrays

我从我的数据库(维度1等)中获取4维,然后运行if语句,这样我不仅可以向用户显示维度,还可以显示相应的反馈。因此,任何类型的“主动”学习者都可以获得相同的反馈。因此,在我的数据库表'ilsFeedback'中,我想提取answerType和studentDefinition,以便我可以在必要时将8种学习类型与相应的反馈相匹配。我已经能够显示维度,以及每个用户需要的反馈类型。在提取所需定义方面苦苦完成其余的工作。任何帮助都将是学徒。感谢

<?php

    $dbQuery = $db->prepare("select dimension1, dimension2, dimension3, dimension4 FROM indexLearningStyle WHERE studentNumber = '".$currentUser."'");
    $dbQuery-> execute();

    while ($dbRow = $dbQuery->fetch (PDO::FETCH_ASSOC)) {
    $dimension1 = $dbRow["dimension1"];
    $dimension2 = $dbRow["dimension2"];
    $dimension3 = $dbRow["dimension3"];
    $dimension4 = $dbRow["dimension4"]; 

    }

    if  ($dimension1 == "Strongly Active"){
        $displayDimension1 = 'active';

    }
    elseif ($dimension1 == "Moderately Active") {
        $displayDimension1 = 'active';

    }
    elseif ($dimension1 == "Mildly Active") {
        $displayDimension1 = 'active';

    }
    elseif ($dimension1 == "Strongly Reflective") {
        $displayDimension1 = 'reflective';

    }
    elseif ($dimension1 == "Moderately Reflective") {
        $displayDimension1 = 'reflective';

    }
    elseif ($dimension1 == "Mildly Reflective") {
        $displayDimension1 = 'reflective';

    }

    if  ($dimension2 == "Strongly Sensing"){
        $displayDimension2 = 'sensing';

    }
    elseif ($dimension2 == "Moderately Sensing") {
        $displayDimension2 = 'sensing';

    }
    elseif ($dimension2 == "Mildly Sensing") {
        $displayDimension2 = 'sensing';

    }
    elseif ($dimension2 == "Strongly Intuitive") {
        $displayDimension2 = 'sensing';

    }
    elseif ($dimension2 == "Moderately Intuitive") {
        $displayDimension2 = 'sensing';

    }
    elseif ($dimension2 == "Mildly Intuitive") {
        $displayDimension2 = 'sensing';

    }

    if  ($dimension3 == "Strongly Visual"){
        $displayDimension3 = 'visual';

    }
    elseif ($dimension3 == "Moderately Visual") {
        $displayDimension3 = 'visual';

    }
    elseif ($dimension3 == "Mildly Visual") {
        $displayDimension3 = 'visual';

    }
    elseif ($dimension3 == "Strongly Verbal") {
        $displayDimension3 = 'verbal';

    }
    elseif ($dimension3 == "Moderately Verbal") {
        $displayDimension3 = 'verbal';

    }
    elseif ($dimension3 == "Mildly Verbal") {
        $displayDimension3 = 'verbal';

    }

    if  ($dimension4 == "Strongly Sequential"){
        $displayDimension4 = 'sequential';

    }
    elseif ($dimension4 == "Moderately Sequential") {
        $displayDimension4 = 'sequential';

    }
    elseif ($dimension4 == "Mildly Sequential") {
        $displayDimension4 = 'sequential';

    }
    elseif ($dimension4 == "Strongly Global") {
        $displayDimension4 = 'global';

    }
    elseif ($dimension4 == "Moderately Global") {
        $displayDimension4 = 'global';

    }
    elseif ($dimension4 == "Mildly Global") {
        $displayDimension4 = 'global';

    }

    $dbQuery = $db->prepare("select studentDefinition FROM ilsFeedback");
    $dbQuery-> execute();

    $result_array = array();
    while($row = mysql_fetch_assoc($dbQuery))
    {
        $result_array[]=$row;
    }

    print_r($result_array);


?>

0 个答案:

没有答案