使用for循环下拉

时间:2016-11-21 09:30:17

标签: php for-loop dropdown

我有这个代码,我想用下拉列表调用单元格,我在这里停留了一个多星期;谁能帮我?代码问题是如何调用,每次单元格为15,并从数据库调用它们。

<?php
$count = 0; 
for ($i = 0; $i < $lessonRows; $i++) {
    $sum = 0;
    require('rowAVG.php');
    if ($average == 100 && $levelPassCounter == 3) {
        $levelPassCounter = 0;
    }
    $average = 0;
    for ($j = 0; $j < 3; $j++) {
        require('lessonSuccess.php');
        if ($counter == 1) {
            if ($prevCoursePass == 0) {
                ?>
                <button type="submit" class="btn"><?php echo $exercize; echo $counter;?></button>
                <?php
            } elseif ($prevCoursePass == 1) {
                if ($success == 1) {
                    $pass++;
                    $lastSuccess = $success;
                    ?>
                    <button type="submit" style="border-bottom: none;" class="btn" disabled><?php echo $exercize; echo $counter;?></button>
                    <?php
                } else {
                    $lastSuccess = $success;
                    ?>
                    <button type="submit" class="btn" name="p" value="<?php echo $exercize; echo $counter;?>" id="test" onclick="changeName(this)"><?php echo $exercize; echo $counter;?></button>
                    <input type="hidden" name="path" id="path" value="<?php if($_SESSION['audio']==1){ echo 'audio/1.php'; } elseif($_SESSION['textles']==1){ echo 'text/1.php'; } else { echo 'courses/1.php'; }?> ">
                    <input type="hidden" name="lessonID" id="lessonID" value="<?php echo $lessID;?>">
                    <input type="hidden" name="courseID" id="courseID" value="<?php echo $courseID;?>">
                    <input type="hidden" name="levelID" id="levelID" value="<?php echo $i+1;?>" >
                    <?php
                }
            } 
        } else {
            if ($lastSuccess == 1) {
                if ($success == 1) {
                    $pass++;
                    $lastSuccess = $success;
                    ?>
                    <button type="submit" style="border-bottom: none;" class="btn" disabled><?php echo $exercize; echo "\t"; echo $counter;?></button>
                    <?php
                } else {
                    $lastSuccess = $success;
                    ?>
                    <button type="submit" style="background: #34495e; border-bottom-color: #2c3e50; box-shadow: 0 0 2px 2px #81CFE0;" class="btn" name="p" value="<?php echo $exercize; echo "\t"; echo $counter;?>" id="test" onclick="changeName(this)"><?php echo $exercize; echo "\t"; echo $counter;?></button>
                    <input type="hidden" name="path" id="path" value="<?php if($_SESSION['audio']==1){ echo 'audio/1.php'; } elseif($_SESSION['textles']==1){ echo 'text/1.php'; } else { echo 'courses/1.php'; }?> ">
                    <input type="hidden" name="lessonID" id="lessonID" value="<?php echo $lessID;?>">
                    <input type="hidden" name="courseID" id="courseID" value="<?php echo $courseID;?>">
                    <input type="hidden" name="levelID" id="levelID" value="<?php echo $i+1;?>">
                    <?php
                } else {
                    ?>
                    <button type="submit" class="btn" style="opacity: .5;" disabled><?php echo $exercize; echo "\t"; echo $counter;?></button>
                    <?php
                }
            }
        }
        $lastAVerage = round($average);
    }
}
?>

1 个答案:

答案 0 :(得分:0)

           <select>
        <?php  $count=0;
        require ('prevTable2.php');
        $sum=0;
        require ('rowAVG.php');
            for($i=0; $i<$lessonRows; $i++):
                if($average==100 && $levelPassCounter==3){?><?php $levelPassCounter=0; }
                $average=0;
                for ($j=0; $j<3; $j++)
                    require ('lessonSuccess.php');?>
        <option value="<?php ?>"> <?php

            echo $exercize;  echo $counter; ?> </option>
         <?php endfor ?>
    </select>