在Modal(Bootstrap)中打印信息

时间:2015-07-05 10:04:20

标签: php mysql twitter-bootstrap modal-dialog

在我的搜索输入中,给出关于以下关键字的结果:

![结果' s] http://i.stack.imgur.com/7VaWl.png

如果点击任何结果,我的目标是通过打开Modal获取更多信息:  http://i.stack.imgur.com/qU36A.png

我想在开放模型上从mysql中选择更多信息。我怎么能这样做?

以下是我的代码:

div.staff div {display: none}

编辑:现在我可以从mysql中选择信息,但只能使用" $ i" ..

<body>
      <h1>חפש פריט</h1>
      <br>
      <form action="search.php" method="post">
      <input type="text" name="keywords" class="form-control" style="width: 250px;margin-left:auto;margin-right:auto;display:inline;" placeholder="הקלד שם של פריט..." /><button type="submit" name="search" class="btn btn-primary">חפש</button>
      </form>
      <br>
      <?php
      $keywords = $_POST['keywords'];
      $ok = 1;
      if(isset($_POST['search'])) {
      if(empty($keywords)) {
      echo '<div class="alert alert-danger fade in">
        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
        <strong>שגיאה:</strong> הקלד מילות חיפוש
      </div>';
      $ok = 0;
      }
      if(!empty($keywords) && !preg_match("/[A-Za-z0-9א-ת\.\,\_\- ]/", $keywords)) {
      echo '<div class="alert alert-danger fade in">
        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
        <strong>שגיאה:</strong> הזנת תווים לא חוקיים
      </div>';
      $ok = 0;
      }
      else if($ok !== 0) {
      $search_sql = mysql_query("SELECT * FROM `list` WHERE `Name` LIKE '%$keywords%';");
      if(mysql_num_rows($search_sql) < 1) {
      $status = "
      <div class='alert alert-warning'>
      <strong>לא מצאנו</strong> תוצאות עבור חיפוש זה ($keywords)
    </div>
    ";
      }
      echo '<div class="container">
      <h2>תוצאות חיפוש</h2>
      <br />
      '.$status.'';
      while($result = mysql_fetch_array($search_sql)) {
      printf('
      <div class="well" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">%s</div><br />
        <div id="myModal" class="modal fade" role="dialog">
      <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Modal Header</h4>
          </div>
          <div class="modal-body">
            <p>Some text in the modal.</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div>

      </div>
    </div>
      ', $result['Name']);
      }
      echo '</div>';
      }
      }
      ?>

但是,它运作不佳。如果我点击任意结果,模态将打开,结果相同: i.stack.imgur.com/SKrka.png

所以,我想要更专业的东西..

1 个答案:

答案 0 :(得分:0)

没关系, 我只是将mys var中的i var替换为结果id 替换这个:

  <div class="well" class="btn btn-info btn-lg" data-toggle="modal" data-target="#openM'.$result['ID'].'">%s</div><br />
<div id="openM'.$result['ID'].'" class="modal fade" role="dialog">

要:

my_dict={}
with open("traits.csv","rb") as f:
   cr = csv.reader(f, delimiter=',', lineterminator='\n')
   for row in cr:
       my_dict.setdefault(row[0].strip('" '),[]).append(row[1].strip('" '))

祝你有愉快的一天! ☺