Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 7th, 2008, 4:53 PM   #1
Abyss
Newbie
 
Join Date: Apr 2005
Posts: 18
Rep Power: 0 Abyss is on a distinguished road
Iterate Drop down boxes?

Hello all! I'm currently writing some code for an online query system. From my page, users are able to select field names from mysql drop down boxes and generally structure the query in plain english. So for example, when they select 'greater than' in a text box I have the value set to '>'.

At present, I've had to duplicate the code for the drop down boxes many times. This makes the code look more complicated than what it is and generally untidy. I was wondering if there is a way to use a loop to generate 5 drop box boxes at once, giving a unique name to each such as Col1, Col2 etc.

I've found the task more difficult since the fields in the drop down boxes are being retrieved from a mySQL database.

Ideally, I would have a button which could generate new drop down boxes at the user's discretion.

Here is the code I'm using to create to drop down menus at present.

<select name="Col1">

<?php
$i = 0;
while ($i < mysql_num_fields($result)){
  $fieldname = mysql_field_name($result, $i);
  echo '<option value="'.$fieldname.'">'.$fieldname.'</option>';
  $i++;
  }
?>
</select><p>

Suggestions/help would be appreciated as always!
Abyss is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down Menu with POST to php or html lago PHP 6 Oct 25th, 2006 8:57 PM
Disable Drop Downlist Using Radio Buttons Ghost JavaScript and Client-Side Browser Scripting 1 Nov 15th, 2005 2:22 PM
Rich Text Boxes brokenhope Visual Basic 1 Sep 7th, 2005 2:34 PM
Help with drop down box Joe Blow HTML / XHTML / CSS 3 Jun 27th, 2005 10:19 AM
HELP!!! Perl script to display drop down menu on webpage domquem Perl 8 Jun 2nd, 2005 9:48 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC