Reputation: 97
I have code
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>
how to put info message that user cant continue (and they cant click the button to continue), if number of rows is not true. Via button onclick. begginer in js sorry. Thanks in advance
Upvotes: 0
Views: 45
Reputation: 2943
Add disabled
attribute of button based on rowCount
<button type="button" name="forform" onclick="" class="hit"
<?php echo ($rowcount1 > 0) ? '' : 'disabled'; ?>>hit</button>
Upvotes: 2
Reputation: 5501
You can do that by put button in if else condition with disable attributes
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>';
}
?>
Upvotes: 0