2017-02-25 39 views
0

我有代碼把信息消息用戶着繼續,如果行數是不正確的

if($rowcount1 > 0){ 
     ?> 
      <h3 class="text-muted"><u>DEPARTURE</u></h3> 
      <h4><?php echo "$origin to $destination "?></h4> 
       <table class="table table-hover"> 
        <thead> 
        <tr> 
         <th>FLIGHT NO.</th> 
         <th>DEPART</th> 
         <th>ARRIVE</th> 
         <th>AIRPORT</th> 
         <th>DURATION</th> 
         <th>FLY ONLY</th> 
         <th>FLY + BAGGAGE</th> 
        </tr> 
        </thead> 
        <tbody> 
        <?php 
         foreach ($query as $flightr) { 
          echo "<tr>"; 
          echo "<td>".$flightr['id']."</td>"; 
          echo "<td>".$flightr['depart']."</td>"; 
          echo "<td>".$flightr['arrive']."</td>"; 
          echo "<td>".$flightr['airport']."</td>"; 
          echo "<td>".$flightr['duration']."</td>"; 
          echo "<td> <label for=lbl7> <input type='radio' checked id='lbl7' name='flight[]' value='".$flightr['flyonly']."'> PHP ".number_format($flightr['flyonly'])."</label></td>"; 
          echo "<td> <label for=lbl8> <input type='radio' checked id='lbl8' name='flight[]' value='".$flightr['flybaggage']."'> PHP ".number_format($flightr['flybaggage'])."</label></td>"; 
          echo "</tr>"; 
         } 
        ?> 
        </tbody> 
       </table> 
       <hr> 
        <?php 

         }else{ 
          echo " <div class='alert alert-info' role='alert'> 
             No results found on <BIG class='text-muted'>Departure</BIG> pick another flight thank you. 
            </div> 
          "; 
         } 
     } 
     } 
    ?> 
    <button type="button" name="forform" onclick="" class="hit">hit</button> 

如何把信息消息着繼續該用戶(以及他們不能按一下按鈕繼續),如果數的行是不正確的。通過按鈕點擊。在js對不起。在此先感謝

回答

2

添加disabled根據rowCount時

按鈕的屬性
<button type="button" name="forform" onclick="" class="hit" 
     <?php echo ($rowcount1 > 0) ? '' : 'disabled'; ?>>hit</button> 
+0

更好然後地雷 – urfusion

+0

仍可繼續,因爲我的按鈕類上有一個js腳本'點擊'也許js函數重寫它?我該怎麼做? –

+0

如果按鈕被禁用,那麼點擊腳本將不會執行 – Naincy

0

你可以做到這一點的放按鈕,如果用禁用的屬性else條件

if ($rowcount1 > 0) { 
    ?> 
    <h3 class="text-muted"><u>DEPARTURE</u></h3> 
    <h4><?php echo "$origin to $destination " ?></h4> 
    <table class="table table-hover"> 
     <thead> 
      <tr> 
       <th>FLIGHT NO.</th> 
       <th>DEPART</th> 
       <th>ARRIVE</th> 
       <th>AIRPORT</th> 
       <th>DURATION</th> 
       <th>FLY ONLY</th> 
       <th>FLY + BAGGAGE</th> 
      </tr> 
     </thead> 
     <tbody> 
    <?php 
    foreach ($query as $flightr) { 
     echo "<tr>"; 
     echo "<td>" . $flightr['id'] . "</td>"; 
     echo "<td>" . $flightr['depart'] . "</td>"; 
     echo "<td>" . $flightr['arrive'] . "</td>"; 
     echo "<td>" . $flightr['airport'] . "</td>"; 
     echo "<td>" . $flightr['duration'] . "</td>"; 
     echo "<td> <label for=lbl7> <input type='radio' checked id='lbl7' name='flight[]' value='" . $flightr['flyonly'] . "'> PHP " . number_format($flightr['flyonly']) . "</label></td>"; 
     echo "<td> <label for=lbl8> <input type='radio' checked id='lbl8' name='flight[]' value='" . $flightr['flybaggage'] . "'> PHP " . number_format($flightr['flybaggage']) . "</label></td>"; 
     echo "</tr>"; 
    } 
    ?> 
     </tbody> 
    </table> 
    <hr> 
    <button type="button" name="forform" onclick="" class="hit">hit</button> 
    <?php 
} else { 
    echo " <div class='alert alert-info' role='alert'> 
             No results found on <BIG class='text-muted'>Departure</BIG> pick another flight thank you. 
            </div> 
          "; 
    echo '<button type="button" name="forform" onclick="" class="hit" disable="disable">hit</button>'; 
} 
?> 
相關問題