erdomester Posted May 4, 2009 Share Posted May 4, 2009 Hey everyone, I would like to list the tables of a MS ACCESS database, but I have not found any solutions yet. Thank You, erdomester Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/ Share on other sites More sharing options...
RichardRotterdam Posted May 4, 2009 Share Posted May 4, 2009 If you want to read an ms access database using php you'll need odbc. Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/#findComment-825619 Share on other sites More sharing options...
erdomester Posted May 4, 2009 Author Share Posted May 4, 2009 No. I have already a program that reads data from a specified table. I just don't know how to manage tables when I don't know their names.. My aim is to put all the tables of the database into an array. Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/#findComment-826026 Share on other sites More sharing options...
premiso Posted May 4, 2009 Share Posted May 4, 2009 http://www.eggheadcafe.com/forumarchives/Access/Jun2005/post23219902.asp SELECT [Name] FROM MSysObjects WHERE [Type] = 6 Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/#findComment-826039 Share on other sites More sharing options...
erdomester Posted May 5, 2009 Author Share Posted May 5, 2009 http://www.eggheadcafe.com/forumarchives/Access/Jun2005/post23219902.asp SELECT [Name] FROM MSysObjects WHERE [Type] = 6 Thank you, this is it, but how can i use this? I understand the structure of a simple query like $sql="SELECT * FROM table_sth"; but retrieving tables names is different.. Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/#findComment-826569 Share on other sites More sharing options...
erdomester Posted May 6, 2009 Author Share Posted May 6, 2009 Found another solution: http://hu.php.net/manual/en/function.odbc-tables.php Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/#findComment-827346 Share on other sites More sharing options...
kickstart Posted May 6, 2009 Share Posted May 6, 2009 Hi From when I had to do this. Pretty crude but works:- $result = odbc_tables($OdbcDatabaseConnectionVar); $tables = array(); while (odbc_fetch_row($result)){ if(odbc_result($result,"TABLE_TYPE")=="TABLE") { echo"<br>".odbc_result($result,"TABLE_NAME")."<br />"; $cols = odbc_exec($OdbcDatabaseConnectionVar,'select * from `'.odbc_result($result,"TABLE_NAME").'` where 1=2'); // we don't want content $ncols = odbc_num_fields($cols); for ($n=1; $n<=$ncols; $n++) { $field_name = odbc_field_name($cols, $n); echo " ".$field_name."<br />"; } } } All the best Keith Link to comment https://forums.phpfreaks.com/topic/156756-solved-how-to-list-ms-access-tables/#findComment-827351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.