'; //make the column headers what you want in whatever order you want echo ' NO EMP.ID COMPANY BRANCH DEPARTMENT FIRSTNAME LASTNAME POSITION '; //loop the query data to the table in same order as the headers $getArea = mysqli_query($conn,$sql); $statRow = mysqli_num_rows($getArea); if($statRow > 0){ while($row = mysqli_fetch_array($getArea)){ $count = $count + 1; echo " ".$count." ".$row['emp_id']." ".$row['comp_id']." ".$row['branch_id']." ".$row['department_id']." ".$row['first_name']." ".$row['last_name']." ".$row['position']." "; } } echo ''; ?>