List tables by name

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

Post Reply
n8r0x
Forum Newbie
Posts: 1
Joined: Tue Jun 07, 2005 2:44 pm

List tables by name

Post by n8r0x »

I've written a nice little MySql content management system for my web site that uses each table as a "directory" and inserts info into each table as a "page".

I'd like to be able to list the tables in alphabetical order. They do so quite nicely on my intranet but once I uploaded the site to a remote serve a difference in settings does not cause this to happen.
here is the code that generates links to each "directory".

Code: Select all

$tables= mysql_list_tables(DB_NAME);
$tab=0;
$i=0;
while ($i < mysql_num_rows($tables)){
	$tbl_name=mysql_tablename($tables,$i);
	//lists all tables but 'users'
		if ($tbl_name=="users"){echo '';}
		else {echo "[<a href=?dir=".$tbl_name." class='dir_nav' tabindex=5".$tab++.">".$tbl_name."</a>]\n";}
	$i++;
	}
output looks like

Code: Select all

&lt;table border=0 class=&quote;dir_nav&quote; width=100%&gt;
	&lt;tr&gt;&lt;td valign=top ALIGN=center&gt;

&#1111;&lt;a href=?dir=TableName class='dir_nav' tabindex=50&gt;TableName&lt;/a&gt;]...ect&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
any help is appreceated
N8
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

your rights could have been revoked for that (I do believe that is possible)...
eitherway you don't check if it failed or not, do that first.
Post Reply