validate if table row has data in every fields - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, June 11, 2021

validate if table row has data in every fields

I want to validate if a current row in every field has data on it and if it has not then display no data. Please help me. Also it is advisable to use echo in displaying the table data or should i stick to the html. Thanks in advance! I've been searching the net and was not able to find some answers. lol

$ct_list = mysqli_query($conn,"select * from ct LEFT JOIN station on ct.station_id=station.station_id LEFT JOIN dilg_emp on dilg_emp.station_id=station.station_id where dilg_emp.dilg_emp_id= $session_id"); 
if (mysqli_num_rows($ct_list) > 0){
    while ($ct_row_list = mysqli_fetch_array($ct_list)) {
        $ct_FName = $ct_row_list['ct_FName'];
        $ct_MName = $ct_row_list['ct_MName'];
        $ct_LName = $ct_row_list['ct_LName'];
        $ct_SName = $ct_row_list['ct_SName'];
        $ct_address = $ct_row_list['ct_address'];
        $ct_birthday = $ct_row_list['ct_birthday'];
        $ct_age = $ct_row_list['ct_age'];
        $ct_gender = $ct_row_list['ct_gender'];
        $ct_level_educ = $ct_row_list['ct_level_educ'];
        $ct_course = $ct_row_list['ct_course'];
        $ct_school = $ct_row_list['ct_school'];
        $ct_prev_covid = $ct_row_list['ct_prev_covid'];
        $ct_training_date = $ct_row_list['ct_training_date'];
        $ct_deployment_date = $ct_row_list['ct_deployment_date'];
        $ct_prev_emp = $ct_row_list['ct_prev_emp'];
        echo "<tr>
            <td>".
        $x++."
            </td>
            <td>
                $ct_FName $ct_MName $ct_LName $ct_SName
            </td>
            <td> 
                $ct_address
            </td>
            <td> 
                $ct_birthday
            </td>
            <td>
                $ct_age
            </td>
            <td>
                $ct_gender
            </td>
            <td>
                $ct_level_educ
            </td>
            <td>
                $ct_course
            </td>
            <td>
                $ct_school
            </td>
            <td>
                $ct_prev_covid
            </td>
            <td>
               $ct_training_date
            </td>
            <td>
                $ct_deployment_date
            </td>
            <td>
                $ct_prev_emp
            </td>
        </tr>";
    }
}else{    
    echo "<tr><td><b>Nothing to display</b></td></tr>";
}


source https://stackoverflow.com/questions/67926815/validate-if-table-row-has-data-in-every-fields

No comments:

Post a Comment