Hi,
I'm searching a way how to get all column names and values from a sql SELECT statement into one array.
Usually I'd use mysqli_fetch_assoc or fetch(PDO::FETCH_ASSOC) but both options doesn't work.
Is there any other possibility?
BR,
Oliver
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
How to get columns and values from database in one array
-
- nuBuilder Team
- Posts: 4566
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 531 times
- Contact:
Re: How to get columns and values from database in one array
Hi,
Something like this?
Something like this?
Code: Select all
function getColumnsArray($table){
$a = array();
$s = "SHOW COLUMNS FROM `$table`";
$t = nuRunQuery($s);
while($r = db_fetch_row($t)){
$a[] = $r[1];
}
return $a;
}
$arr = getColumnsArray('your_table_name_here');
Re: How to get columns and values from database in one array
Thank you. That is was I'm looking for!
-
- Posts: 249
- Joined: Sun Dec 06, 2020 6:50 am
- Location: Chennai, India, Singapore