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!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
How to get columns and values from database in one array
-
- nuBuilder Team
- Posts: 4304
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 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