Current location: Hot Scripts Forums » Programming Languages » PHP » Generate form from unknown number of database fields?


Generate form from unknown number of database fields?

Reply
  #1 (permalink)  
Old 07-11-05, 11:56 AM
Tim Mousel Tim Mousel is offline
Wannabe Coder
 
Join Date: Jan 2005
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
Question Generate form from unknown number of database fields?

Hi,

Here's the scenario:

From an admin panel, the admin creates a table that has the following fields:
item, name, rating, rating1, rating2, rating3, etc...

Each rating field will have a name associated with it such as:
Quality (rating1), Durability (rating2), Satisfaction (rating3), etc...

It could be an unlimited amount of rating[$i] fields.

Now, on the user side, how would I dynamically create my form based on the unknown number of fields in the database?

Hope that makes sense!

Thanks,

Tim
Reply With Quote
  #2 (permalink)  
Old 07-11-05, 12:04 PM
koncept
Guest
 
Posts: n/a
i know asp, but in there we do

this should give you the idea(s) and then be able to convert it.
Code:
 	<table border="1" cellspacing="0">
 	  <tr>
 	  <% For i = 0 to rsCustomQuery.Fields.Count - 1 %>
 		    <TD><B><% = rsCustomQuery(i).Name %></B></TD>
 			<% Next %>
 	  </tr>
 	  <%
 		Do While Not rsCustomQuery.EOF
 		  %>
 	  <tr>
 			<% For i = 0 to rsCustomQuery.Fields.Count - 1 %>
 		    <TD VALIGN=TOP><% = rsCustomQuery(i) %></TD>
 			<% Next %>
 	  </tr>
 		  <%
 			rsCustomQuery.MoveNext
 			Loop
 	  %>
   </table>
Reply With Quote
  #3 (permalink)  
Old 07-11-05, 08:30 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
'SHOW FULL FIELDS FROM table'

That query should return all the fields
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
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
How to make read-only form fields Ashantai JavaScript 4 02-15-05 04:26 PM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Add sequential number to database from checkbox ajndede ASP 1 05-04-04 07:43 AM
displaying fields on the same form aliasgar ASP 1 01-22-04 12:50 PM
SQL database registration form help vinhkhuong PHP 3 10-10-03 03:49 AM


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