PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 19th, 2004, 10:38 PM
twister twister is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 twister User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP and MYSQL Database Tables

What I am wanting to do is create a dropdown box with all the tables that are listed in a particular database. I have a form that I can add data to a table in the database and I would like to be able to choose the table that the data gets added to. EXAMPLE : I have a database named Test. In this database I have table A, B, and C. The tables represent locations but the columns inside the table contain the same data : First Name, Last Name, and Phone Number. The form is generic populating the fields First Name, Last Name, and Phone Number. Now I would like a drop down at the top that I can select a table from to populate the data. I hope this makes sencebut if not I will try to explain a little better if needed. Thanks in advance for any help provided.

Reply With Quote
  #2  
Old August 20th, 2004, 04:19 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 997 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 14 h 26 m 27 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
Something like this?
PHP Code:
 mysql_connect(/*your connection info */);
mysql_select_db("Test");

$result mysql_query("SHOW TABLES");
echo 
"<select name=\"db_name\">\n";
while(
$temp mysql_fetch_array($result))
    echo 
"<option value=\"".$temp['Tables_in_Test']."\">".$temp['Tables_in_Test']."</option>\n";
echo 
"</select>\n"


After the submit, you can read the data to populate the table with:
PHP Code:
 $query "SELECT * FROM ".$_POST['db_name']; 


Hope it helps

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP and MYSQL Database Tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT