Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide table row?

Tags:

html

php

mysql

rows

I am trying to hide the table row for user_id. I only want to show the full name, user name, and actions in the table. I tried to remove the code for the user id row, but it affected the other functionalities like the edit and delete.

here is the code:

<form method="post" id="editForm"> 
    <table class="table">
        <tbody>
        <tr>
                <th scope="col">USER ID</th>
                <th scope="col">FULL NAME</th>
                <th scope="col">USER NAME</th>
                <th scope="col">ACTIONS</th>
        </tr>
        
        <?php $a = 0?>

        <?php while ($row = mysqli_fetch_array($res)) { 

            echo "<tr id=".$a++.">
                <th scope='row' class='row-data'>".$row['user_id']."</th>
                <td class='row-data'>".$row['full_name']."</td>
                <td class='row-data'>".$row['user_name']."</td>
                <td><input type='button' 
                        value='EDIT'
                           onclick='editUser()'' /></td>
                <td><input type='button' 
                         value='DELETE' 
                   onclick='deleteUser()' /></td>
            </tr>
        
        </tbody>";
       }; ?>
like image 452
Just Kroosing Avatar asked Feb 06 '26 22:02

Just Kroosing


1 Answers

Instead of removing the column, you can set the display style to 'none' for this column

(add style="display:none;")

Hence (1) change

<th scope="col">USER ID</th>

to

<th scope="col" style="display:none;">USER ID</th>

and (2) change

<th scope='row' class='row-data'>".$row['user_id']."</th>

to

<th scope='row' class='row-data' style="display:none;">".$row['user_id']."</th>
like image 179
Ken Lee Avatar answered Feb 09 '26 12:02

Ken Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!