Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old September 30th, 2002, 01:16 AM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
autogen of admin pages

doing some crazy stuff again.

This time I want to autogen an admin page for a database table, just basically instead of having to write each form etc. They are all pretty similar so why not auto gen??

anyway, what I need to do is get the field names from the table as well as the data.

Is this possible???

I have had a quick look through the manual and can;t find anything good, but I will continue.

Any ideas?

Reply With Quote
  #2  
Old September 30th, 2002, 01:22 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: autogen of admin pages

If its MySQl, check out the

mysql_field_name function

also the

mysql_num_fields function

you can do something like:

php Code:
Original - php Code
  1. <?
  2. $result = mysql_query("SELECT * FROM TABLE LIMIT 1");
  3.  
  4. for($i = 0; $i < mysql_num_fields($result); $i++) {
  5.   echo mysql_field_name($result, $i);
  6. }
  7. ?>

Reply With Quote
  #3  
Old September 30th, 2002, 02:57 AM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: autogen of admin pages

thanks

Reply With Quote
  #4  
Old September 30th, 2002, 10:26 PM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: autogen of admin pages

one step further - how do I get the values for enums?

Reply With Quote
  #5  
Old September 30th, 2002, 10:42 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: autogen of admin pages

As a follow up to the first question, you can also use mysql_list_fields:

php Code:
Original - php Code
  1. <?
  2. $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
  3.  
  4. $fields = mysql_list_fields("database1", "table1", $link);
  5.  
  6. for($i = 0; $i < mysql_num_fields($result); $i++) {
  7.   echo mysql_field_name($fields, $i) . "n";
  8.  
  9. }
  10. ?>

Reply With Quote
  #6  
Old September 30th, 2002, 10:44 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: autogen of admin pages

As for who to get the enum values...I can't think of a function to perform that...you can use a query like this though:

select distinct(enumfield) from table

that should return the values one per a row...


Reply With Quote
  #7  
Old September 30th, 2002, 10:54 PM
madhombre madhombre is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: WI
Posts: 247 madhombre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: autogen of admin pages

thanks again, it is working, I actually found a nice little function to do it, on the php manual.

it works like a charm.

I will let you know if I hit anything else!


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > autogen of admin pages


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 5 hosted by Hostway