2017-11-10 3 views
-2

私は小さな問題がありますが、私は24の異なるケースでモーダルを使用しなければなりません。このIDをモーダルIDでテストして結果を表示するには、モーダルで。私はよく表現したかどうかわからない!しかし、ここであなたが手動ですべてのあなたの24個のモーダルを作成しているようだコードモーダルで使用するための変数を復帰します

<!-- Modal --> 
 
       <?php 
 
       $x=7; 
 
       $case = $fun -> getCaseByIde($x); 
 
       ?> 
 
       <div id="myModal-<?php echo $x; ?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
 
        <div class="modal-dialog modal-lg"> 
 
         <!-- Modal content--> 
 
         <div class="modal-content" style="text-align: center;"> 
 
          <div class="modal-header"> 
 
           <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
           <h1><?php echo $x; $case['titre']; ?></h1> 
 
          </div> 
 
         </div> 
 
        </div> 
 
       </div> 
 
       <!-- #END# Modal --> 
 
       <!-- Modal --> 
 
       <?php 
 
       $x=8; 
 
       $case = $fun -> getCaseByIde($x); 
 
       ?> 
 
       <div id="myModal-<?php echo $x; ?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
 
        <div class="modal-dialog modal-lg"> 
 
         <!-- Modal content--> 
 
         <div class="modal-content" style="text-align: center;"> 
 
          <div class="modal-header"> 
 
           <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
           <h1><?php echo $x; $case['titre']; ?></h1> 
 
          </div> 
 
         </div> 
 
        </div> 
 
       </div> 
 
       <!-- #END# Modal --> 
 
       <!-- Modal --> 
 
       <?php 
 
       $x=9; 
 
       $case = $fun -> getCaseByIde($x); 
 
       ?> 
 
       <div id="myModal-<?php echo $x; ?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
 
        <div class="modal-dialog modal-lg"> 
 
         <!-- Modal content--> 
 
         <div class="modal-content" style="text-align: center;"> 
 
          <div class="modal-header"> 
 
           <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
           <h1><?php echo $x; $case['titre']; ?></h1> 
 
          </div> 
 
         </div> 
 
        </div> 
 
       </div> 
 
       <!-- #END# Modal -->

+2

英語でお願いします。 – aynber

+0

こんにちは、私は小さな問題がある、私は24の異なるケースのためにモーダルを使用しなければならない、私はモーダルIDでこのidをテストし、モーダルに結果を表示するモーダルに入る前にIDを取得する必要があります。私はよく表現したかどうかわからない!しかしここにコードがあります –

+0

コメントとして追加するのではなく、より良い概観のためにあなたの追加情報をあなたの質問に編集してください;) – BenRoob

答えて

0

のですか?

がループためを使用してみてください:それはあなたの問題ではない場合

<?php 
$modalCount = 24; // Number of modals you want to create. (Nombre de modals à créer) 

// Create a modal from 0 to 23. (Créer un modal de 0 à 23) 
// Use "$x = 1" and "$x <= $modalCount" if you want from 1 to 24. (Utilise ... si tu veux de 1 à 24) 
for ($x = 0 ; $x < $modalCount ; $x++): ?> 

<!-- Modal --> 
<?php $case = $fun->getCaseByIde($x); ?> 

<div id="myModal-<?php echo $x; ?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog modal-lg"> 
     <!-- Modal content--> 
     <div class="modal-content" style="text-align: center;"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal">&times;</button> 
       <h1><?php echo $x; $case['titre']; ?></h1> 
      </div> 
     </div> 
    </div> 
</div> 

<!-- #END# Modal --> 

<?php endfor; ?> 

、より正確にしてください。

+0

はい問題は解決しました!お元気ですか? –

関連する問題