Q:

How to arrange values alphabetically in php in their own cloumn

I have arranged values alphabetically according to their starting alphabet 
    section, values starting with A to be under the A column header, and 
    companies starting with B to be under the B header...or if i have no value 
    with the value of B then B be skipped.  And to show just 5 values... But 
    problem is that values seprating from their column headers and i wants to show then in their own cloumn header...here is my 
    code. 
  <? php
    $sql = "select company_name from companies ORDER BY company_name ";
    $result = mysqli_query($con, $sql);
    while($data = mysqli_fetch_assoc($result)){
       $company = $data['company_name'];
       creatCompanyList($company, $letter,$count);
     }
   $count = 0;  
   $letter = '';
    //echo $count;
  function creatCompanyList($company, &$letter, &$count){
    // echo $count;
    if($letter ! == $company[0]) {
       if($count >0) { 
          endCompanyList();
          $count = 0;
      }
      $letter = $company[0];
      startCompanyList($letter, $count);
    }
   if($letter == $company[0] && $count <= 4) addCompanyList($company);
   if($count==4) endCompanyList();
     $count++;
  }
  function startCompanyList($letter, &$count){
  ? >
  <li class="loop-entry">
    <div class="col"> <span><?php echo $letter?></span>
      <div class="list-col">
  <? php
   }
  function endCompanyList(){
    ? >
    </div>
  </div>
  </li>         
  <? php
  }
 function addCompanyList($company){
 ? >
 <a href="#"><?php echo $company?></a>
 <? php
 }
 ? >

This is screen shot of webpage and i wants the values of E in E column header

A:

Your code considers lowercase and uppercase of a letter not the same.  Fixed that by including strtolower() condition in your if statements. 
Also added strtoupper() for your header letter so it always appears uppercase in case lowercase letter is passed as header. 
Updated Code:
  <? php

    $sql = "select company_name from companies ORDER BY company_name ";
    $result = mysqli_query($con, $sql);
    while($data = mysqli_fetch_assoc($result)){
       $company = $data['company_name'];
       creatCompanyList($company, $letter,$count);
     }
   $count = 0;  
   $letter = '';
    //echo $count;
  function creatCompanyList($company, &$letter, &$count){
    // echo $count;
    if(strtolower($letter) ! == strtolower($company[0])) {
       if($count >0) { 
          endCompanyList();
          $count = 0;
      }
      $letter = $company[0];
      startCompanyList($letter, $count);
    }
   if(strtolower( $letter ) == strtolower( $company[0] ) && $count <= 4) addCompanyList($company);
   if($count==4) endCompanyList();
     $count++;
  }
  function startCompanyList($letter, &$count){
  ? >
  <li class="loop-entry">
    <div class="col"> <span><?php echo strtoupper( $letter )? ></span>
      <div class="list-col">
  <? php
   }
  function endCompanyList(){
    ? >
    </div>
  </div>
  </li>         
  <? php
  }
 function addCompanyList($company){
 ? >
 <a href="#"><?php echo $company?></a>
 <? php
 }
 ? >

