Current location: Hot Scripts Forums » Programming Languages » PHP » question about tables


question about tables

Reply
  #1 (permalink)  
Old 12-05-08, 01:57 PM
mejnoona mejnoona is offline
Newbie Coder
 
Join Date: Aug 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
question about tables

I have not had luck in finding what I want to accomplish so I don't know if this is possible. Is there a way to display in a table on an html page the names of the tables in a mysql database? And then when the user clicks on the table name, they will be taken to another page that is more specific to that table and more specific queries can be done regarding that table?
But at the moment all I want to do is create a script that displays the names of the tables only.
Thanks
Reply With Quote
  #2 (permalink)  
Old 12-05-08, 02:41 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #3 (permalink)  
Old 12-05-08, 03:57 PM
mejnoona mejnoona is offline
Newbie Coder
 
Join Date: Aug 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Thats the command I was thinking of Thanks
I put in this code though but once again, no output. Remembering the last time I had no output, I tried this with mysql_fetch_arrow and mysql_fetch array but still no output comes on the site. any ideas?

<?php

$query="SHOW TABLE STATUS LIKE 'tablename'";
$result=mysql_query($query);

while($row=mysql_fetch_row($result))
{
echo "<br><br> Table Name:". $row[Name] ."<br />";
}

?>
Reply With Quote
  #4 (permalink)  
Old 12-05-08, 04:09 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
mysql_fetch_row() returns a numerical array, so $row['Name'] won't exist...

www.php.net/mysql_fetch_row
Reply With Quote
  #5 (permalink)  
Old 12-05-08, 04:52 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Some simple code that will display all of the tables in a database:

PHP Code:

$alltables mysql_query("SHOW TABLES");

while (
$table mysql_fetch_assoc($alltables)){

   foreach (
$table as $db => $tablename){

      print 
"Table: $tablename <br />";

   }

__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]

Last edited by End User; 12-05-08 at 04:56 PM.
Reply With Quote
  #6 (permalink)  
Old 12-05-08, 08:03 PM
mejnoona mejnoona is offline
Newbie Coder
 
Join Date: Aug 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks that did work. Thats a new fetch command....man, I cant wait til I get to the point where I can write code on the fly and not run into so many steping stones Thanks again!
Reply With Quote
  #7 (permalink)  
Old 12-06-08, 02:19 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Browsing the relevant section in the php manual is an excellent way to find out what functions are available and what they do - http://us2.php.net/mysql
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Injecting a string into an If Statement ? nova912 PHP 4 07-21-06 02:04 PM
REQUEST: Tutorial or prmg on mysql/php/related tables chippewapublishing Script Requests 0 08-05-05 01:50 PM
tables and PHP, odd question eq1987 PHP 3 07-04-04 12:30 PM
need help creating tables in mysql (VERY SIMPLE QUESTION) meaculpa1113 PHP 2 03-26-04 12:32 AM
question and answer software jaydifox C/C++ 0 02-21-04 09:26 AM


All times are GMT -5. The time now is 08:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.