Assign key name based on row while loop
There is no identifiable difference between your table's column names and your preferred keys, but if you want to alter the keys, just build that into your SELECT clause -- this is what "aliases" are for.

Suppose you wanted to capitalize each column name, here's how that could look:

$stmt = $conn-&gt;prepare("SELECT name AS Name,
                               company AS Company,
                               email AS Email,
                               phone AS Phone,
                               address AS Address
                        FROM tickets_info
                        WHERE ticket = ?");
$stmt-&gt;execute([$_POST['ticket']]);
$ticket = $stmt-&gt;fetch(PDO::FETCH_ASSOC) ?: [];


Note, I am not using a loop.  Your snippet is overwriting itself in the loop, so I am interpreting that to mean that ticket is a PRIMARY/UNIQUE column.



If you want to extract all columns from your table and use the column names as keys, you don't need to change your original query.

$stmt = $conn-&gt;prepare("SELECT * FROM tickets_info WHERE ticket = ?");
$stmt-&gt;execute([$_POST['ticket']]);
$ticket = $stmt-&gt;fetch(PDO::FETCH_ASSOC) ?: [];