My code is not working. I'm trying to disable a button based on data from a table cell. This is an example of my table.
Table A (tickets)
*----------------*
| id | repair_id |
| 1 | 10, 11 |
| 2 | 12 |
*----------------*
and my current code:
<?php
$sql = "SELECT repair_id FROM tickets WHERE t_id =".$ticket_id." ";
$sql .= "AND repair_id REGEXP ',' ";
$box_check = mysqli_query($connection, $sql);
$box_empty = mysqli_fetch_array($box_check);
if(count($box_empty) == 0) {
echo "<button class='btn btn-primary' disabled='disabled' name='add_box'>Add Box</button>";
} else {
echo "<button class='btn btn-primary' type='submit' name='add_box'>Add Box</button>";
}
?>
My goal is to allow the box to be active so long as there is more than 1 id
in repair_id
.
Currently the box is disabled or enabled on all depending on if I set if(count($box_empty) == true/false/0/1)
.