2017-11-10 6 views
-2

작은 문제가 있습니다. 24 가지 경우에 모달을 사용해야합니다.이 ID를 모달 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

예 문제가 해결되었습니다 !! 너의 도움을 위해 고맙다. –