Friday, 7 September 2018

Check if any row of the group by is empty

I am checking all rows of the group by, In-case of empty row in a particular group I want to disable all the group column, as in the following script. And I am using group by thats why its not disabling the related column button. How to disable button of a group column if any of it row is empty?

PHP

$id = $_POST['idd'];
        $sql = $db->prepare("SELECT a, b, c from table  WHERE id = :id group by a");
        $sql ->bindparam(':id',$id);
        $sql ->execute();   
        while($row = $sql ->fetch(PDO:: FETCH_ASSOC) ) {
                $a = $row['a'];
                $b = $row['b'];
                $c = $row['c'];
                if(!empty ($c))
                    {
                        echo '<tr>
                        <td><input type="button" name="a[]" value="'.$a.'"></td>
                        <td><input type="button" name="b[]" value="'.$b.'"></td>
                        </tr>';
                    }else{
                        echo '<tr>
                        <td><input type="button" name="a[]" value="'.$a.'" disabled></td>
                        <td><input type="button" name="b[]" value="'.$b.'" disabled></td>
                        </tr>';
                    }

        } // while



from Check if any row of the group by is empty

No comments:

Post a Comment