Jump to content


Photo

SHOW TABLES Query Help


  • Please log in to reply
3 replies to this topic

#1 Tudhope

Tudhope
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 December 2003 - 07:51 AM

I want to get a list of all tables in a database, at the moment im using\"
$tables = mysql_query(\"SHOW TABLES FROM games\");

\'games\' being the database name. This ok but its sent back unorded. I get r1, r11, r12, r13, r14 ..... r19, r2, r20, r21, r22. The name of the tables are r1 through to r22. So I tried out:
$tables = mysql_query(\"SHOW TABLES FROM games SORT BY Asc\");
but this doesnt work. How can i order what is return so that i get, r1 r2 r3 r4 r5.......? Any ideas?

#2 nysebamse

nysebamse
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationBergen, Norway

Posted 15 December 2003 - 08:12 AM

This should sort it out:
http://no.php.net/ma...list-tables.php
Go get Firefox![br][br]http://www.mozilla.org/

#3 Tudhope

Tudhope
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 December 2003 - 08:59 AM

Thats what i was using before but it says that it is deprecative.

****
This function has been deprecated. Do not use this function. Use the command SHOW TABLES FROM DATABASE instead.
***

Hence im trying to use the code above ^^^^

#4 nysebamse

nysebamse
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationBergen, Norway

Posted 15 December 2003 - 09:20 AM

Then this might solve it:
<?php   $dbname = \'db_name\';   if (!mysql_connect(\'localhost\', \'user\', \'password\'))   {        print \'Could not connect to mysql\';        exit;   }		mysql_select_db("$dbname");	$query = "show tables";	$result = mysql_query($query);	$num_results = mysql_num_rows($result);	print "There are $num_results tables.<br>";	for ($i = 0; $i < $num_results; $i++)  {  	$row = mysql_fetch_array($result);  	print "table: " . $row[0] . "<br>";  }?>

Go get Firefox![br][br]http://www.mozilla.org/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users