HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/content-sp/work-sp/nqb_master_transfer_treeview.php
<?php

$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
$SP_MEDIUM = 'csp_sp_medium';
$SP_QUESTION = 'csp_sp_question';

$getMainTopic = $conn->query("SELECT category_name,sub_id FROM $SP_MASTER_STRUCTURE where sub_id='$from_in_id' order by display_order");
$main = $getMainTopic->fetch_assoc();
/************ */
$tree_sub_id = $main['sub_id'];
$subjectQ = $conn->query("SELECT count(question_id) as total_q FROM $SP_QUESTION where master_id='$from_master' and subject_id='$tree_sub_id'");
$countSubQ = $subjectQ->fetch_assoc();
?>
<!----Main Subject----->
<ul>
    <li><?php echo $main['category_name']; ?>&nbsp;(<?php echo $countSubQ['total_q']; ?>)</li>
    <?php

    $getTopics = $conn->query("SELECT sub_id,category_name FROM $SP_MASTER_STRUCTURE where parent_id='$tree_sub_id' order by display_order");
    foreach ($getTopics as $t) {
        /************ */
        $tree_last_sub = $t['sub_id'];
        $topicQ = $conn->query("SELECT count(question_id) as total_q FROM $SP_QUESTION where master_id='$from_master' and topic_id='$tree_last_sub'");
        $countTopQ = $topicQ->fetch_assoc();
    ?>
        <!----Main Subject topics----->
        <ul>

            <?php
            $tree_last_sub = $t['sub_id'];
            $getSubtopic = $conn->query("SELECT sub_id,category_name FROM $SP_MASTER_STRUCTURE where parent_id='$tree_last_sub' order by display_order");
            $ifSubExist = mysqli_num_rows($getSubtopic);
            if ($ifSubExist > 0) {
                echo "<li>" . $t['category_name'] . "</li>";
                foreach ($getSubtopic as $st) {
                    $tree_last_subtopic = $st['sub_id'];
                    $subtopicQ = $conn->query("SELECT count(question_id) as total_q FROM $SP_QUESTION where master_id='$from_master' and sub_topic_id='$tree_last_subtopic'");
                    $countsubTopQ = $subtopicQ->fetch_assoc();
            ?>
                    <!----Main SUbject topics subtopics----->
                    <ul>
                        <li style="padding: 0 0 5px 0;"><input type="radio" class="radio_ans" name="in_sub_id" value="<?php echo $st['sub_id']; ?>" style="margin:8px 0 8px 0;"><?php echo $st['category_name']; ?>&nbsp;(<span id="tpId_<?php echo $st['sub_id']; ?>"><?php echo $countsubTopQ['total_q']; ?></span>)</li>
                    </ul>
                <?php
                }
            } else { ?>
                <li style="padding:0 0 5px 0;">
                    <input type="radio" class="radio_ans" name="in_sub_id" value="<?php echo $t['sub_id']; ?>" style="margin:8px 0 8px 0;">
                    <?php echo $t['category_name']; ?>&nbsp;(<span id="tpId_<?php echo $t['sub_id']; ?>"><?php echo $countTopQ['total_q']; ?></span>)
                </li>
            <?php
            }
            ?>
        </ul>
    <?php
    }
    ?>
</ul>