How to return a selected row (of a database) into a PHP array, with the un-determined number of colunms?

I have a SQL table, which is named tbl_0, and there is some data of it.

+------+---------+---------+---------+
|  id  |  col_1  |  col_2  |  col_3  |
+------+---------+---------+---------+
|  11  |  1_k_1  |  2_k_1  |  3_k_1  |
|  12  |  1_k_2  |  2_k_2  |  3_k_2  |
|  13  |  1_k_3  |  2_k_3  |  3_k_3  |
+------+---------+---------+---------+

Now, I want to get an SQL row into a PHP array. Example: when I call function getrow(11);, it return for me a PHP array: ('1_k_1', '2_k_1', '3_k_1');; when I call function getrow(12);, it return for me a PHP array: ('1_k_2', '2_k_2', '3_k_3');.

My queston is: “How to return a selected database row into a PHP array, with the un-determined number of colunms?”.


Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.