php - How to set the sql results index value by desired column name in mysql?
How can I set the sql results index value by desired column name in mysql? For example
Table name: country
+
create table query is as follows:
{-code-2}
and insert data to table is as follows:
{-code-3}
In result will show like this way:
If I execute the following query and my desired result as bellow:
{-code-4}
Desired result:
{-code-5}
I need the array keys will be the code by direct SQL query. Is it possible?
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Answer
Solution:
Very easy to do this using
, its
method and the build of the keys you need using the
function, as described in these steps:
The code may look something like this:
Which will give you exactly the output you desire.
Answer
Solution:
It's a simple loop reading the results:
Answer
Solution: