Bootstrap包含php里面的模态

时间:2014-03-03 21:08:23

标签: php twitter-bootstrap

所以我试图插入一个php脚本,将select元素的值转换为模态。但PHP脚本工作并获得正确的信息。但每当我尝试将脚本加载到模态中时如下:

<?php include 'script.php' ?>

我的模态不会出现。这些是我的文件:

的index.php

<div class="modal fade" id="upload" tabindex="-1">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h4 class="modal-title">Tilføj en note</h4>
    </div>
    <form action="scripts/upload.php" method="post" enctype="multipart/form-data">
    <div class="modal-body">
      <div class="form-group">
        <label for="name">Navn:</label>
        <input type="text" class="form-control" name="name" placeholder="Navn på note..">
      </div>
      <div class="form-group">
        <label for="name">Fag:</label>
        <select class="form-control">
          <?php include 'scripts/getClasses.php'; ?>
        </select>
      </div>
      <div class="form-group">
        <label for="name">Beskrivelse:</label>
        <textarea name="description" data-provide="markdown" rows="10"></textarea>
      </div>
      <label for="file">Vælg fil:</label>
      <input type="file" name="file" id="file"><br>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" data-dismiss="modal">Luk</button>
      <button type="submit" class="btn btn-success">Upload</button>
    </div>
    </form>
  </div><!-- /.modal-content -->
</div><!-- /.modal -->

脚本/ getClasses.php

<?php
    require 'funcs.php';
    $function = new functions;
    $class = $function->getClasses();

    $numclasses = count($class);
    for($i=0;$i<$numclasses;$i++)
    {
        $id = $class[$i]['id'];
        $name = $class[$i]['name'];

        echo "<option value='".$id."'>".$name."</option>";
    }
?>

funcs.php的片段

public function getClasses()
        //Function that gets all the classes. Used when user adds a new note.
        {
            require 'connect.php';
            $count = 0;
            $q = $db->prepare('SELECT * FROM classes ORDER BY name ASC');
            $q->execute();
            while($row = $q->fetch())
            {
                $results[$count]['id'] = $row['id'];
                $results[$count]['name'] = $row['name'];
                $count++;
            }

            return $results;
        }

0 个答案:

没有答案