PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
hward
Forum Contributor
Posts: 107 Joined: Mon Apr 19, 2004 6:19 pm
Post
by hward » Fri Oct 22, 2004 2:45 am
i can get this to work and it prints out the tables just fine but i want to be able to use them in a display block and can't figure out how to do it.
Code: Select all
<?php
mysql_connect("localhost", "user", "password");
$result = mysql_list_tables("db_name");
$num_rows = mysql_num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
echo "Table: ", mysql_tablename($result, $i), "\n";
}
mysql_free_result($result);
?>
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Fri Oct 22, 2004 3:55 am
do you mean in a table?
hward
Forum Contributor
Posts: 107 Joined: Mon Apr 19, 2004 6:19 pm
Post
by hward » Fri Oct 22, 2004 10:19 am
no i want to list the tables in the database not not the records in a table
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Fri Oct 22, 2004 10:55 am
Maybe you should see that link I posted.
hward
Forum Contributor
Posts: 107 Joined: Mon Apr 19, 2004 6:19 pm
Post
by hward » Fri Oct 22, 2004 11:11 am
that lists all the records in a table not the tables in a database though
kettle_drum
DevNet Resident
Posts: 1150 Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England
Post
by kettle_drum » Fri Oct 22, 2004 2:38 pm
But the link on the page Sami provided you will link you to the mysql_list_tables() function. We are trying to help you to learn on these forums - not just give you complete answers. Help us help you by at least looking at links people post.
sakaveli
Forum Commoner
Posts: 60 Joined: Tue Apr 06, 2004 9:42 am
Post
by sakaveli » Fri Oct 22, 2004 5:21 pm
well said kettle, i think im getting the hang of php and mysql after a whole year of posting my problems on this forum!
its a long journey but there is always light guiding you (in the form of a kettle)