'; //make the column headers what you want in whatever order you want echo ' ID 1 CODE 2 NAME DESCRIPTION '; //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)){ echo "".$row['comp_id']." ".$row['comp_group_code']." ".$row['comp_area_code']." ".$row['comp_code']." ".$row['comp_name']." "; } } echo ''; ?>