Current location: Hot Scripts Forums » Programming Languages » PHP » Add "Not Applicable" to form field list from database


Add "Not Applicable" to form field list from database

Reply
  #1 (permalink)  
Old 04-28-05, 10:57 AM
CutAndPaste's Avatar
CutAndPaste CutAndPaste is offline
Newbie Coder
 
Join Date: Mar 2005
Location: London, UK
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Question Add "Not Applicable" to form field list from database

Hi,

I'm using the following include to return a list of companies in from a directory listing database. This list is used in an online ofrm and is NOT linked to the db in any other way.

It all works great. BUT what I'd like is to allow a "Not Applicable" to be the default option in this list. Is this possible and how would I do it?

Code:
<?
error_reporting( E_ERROR | E_PARSE );

require_once( 'conf/config.inc.php'  );
require_once( 'mysql.class.php' );


//-------------------------------------


$oDb = new MySQL( $aCfg['db_host'], $aCfg['db_name'], $aCfg['db_user'], $aCfg['db_pass'], true );

$sList = '';

if ( $oDb->Connect() )
{
   $hQRes = $oDb->ExecQuery( "SELECT {$aCfg['db_field']} AS fld_alias FROM {$aCfg['db_table']} where firmstate='on' ORDER by {$aCfg['db_field']}" );
   while ( $aRes = $oDb->FetchArray($hQRes) )
   {
      $sTmp = addslashes( $aRes['fld_alias'] );
      $sList .= "<option value='$sTmp'>$sTmp</option>\n";
   }
   echo $sList;
}
else
{
//   print_r( $oDb->aErrors[count($oDb->aErrors)-1] );
}

?>[
Thanks,

Simon
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
Use MySql field as source for form select field CutAndPaste PHP 3 03-14-05 09:35 PM
Multiple form fields saved in one mysql field?? cebuy PHP 4 10-15-04 12:08 PM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
SQL database registration form help vinhkhuong PHP 3 10-10-03 03:49 AM


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