Welcome to PHP Smarty Q&A, where you can ask programmaing questions and receive answers from other members of the community for PHP, Smarty, MYSQL related. You can also share or save your scripts in this repository for future reference.
Bulk SMS Marketing

Getting column names from MySQL using ADODB PHP

+1 vote
56 views
I want to fetch column names of my table using adodb php. Can any one help me please?

Example:

My table has 4 columns `name1, name2, name3, name4` How can I use a query to fetch this as?
asked Jun 5, 2015 in PHP by anonymous

1 Answer

0 votes
 
Best answer

Assuming you have the following connection with your MySQL, here how it is:

$query = "SELECT `name1`, name2`, `name3`, `name4` FROM `mytable`";
$conn->SetFetchMode(ADODB_FETCH_ASSOC);
$rs = $conn->Execute($query);
foreach( $rs as $column => $value ){
    echo "My Column names are : $column";
} 

Good Luck. :)

answered Jun 5, 2015 by robert (13,210 points)
...