If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Handling Webform Checkbox Values with C

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-06, 12:46
niczak niczak is offline
Registered User
 
Join Date: Nov 2006
Posts: 6
Handling Webform Checkbox Values with C

Okay, here is my SQLUpdate function, how can I write a separate function that will handle boolean values, rather than strings? My database table contains 7 boolean fields that are by default set to false, but if the user checks any number of the checkboxes I need the appropriate field to be populated with a 't', rather than the default 'f'.

Code:
void fAddField_SQLUpdate(Tform_rec *pparms, char *pcmd, char *pform_field, 
       char *pdb_field, int bvis_too) {

/* add specified field and value to SQL command string; clean up    */
/*   values as we go                                                */
/* string ultimately comprises a SQL update-existing-record command */

  char *pstr;
  char sbuf[iBUFSIZE], sval[iBUFSIZE];

/* if Web form value is not found, don't do anything                 */
/* note: even if value is empty string, we still need to process it, */
/*   as it may be replacing a previous non-empty value               */

  if ((pstr = fWeb_Form_Val(pparms, pform_field)) == NULL)
    return;

  fCleanUpValue(sval, sizeof(sval), pstr);
  sprintf(sbuf, ",%s='%s'", pdb_field, sval);
  strcat(pcmd, sbuf);

/* if saving visibility flag, construct appropriate field names */
/*   and add current value                                      */

  if (!bvis_too)
    return;

  sprintf(sbuf, "%s%s", pform_field, sVIS_SUFFIX);
  if (((pstr = fWeb_Form_Val(pparms, sbuf)) == NULL) || !strlen(pstr))
    return;

  sprintf(sbuf, ",c%s%s='%s'", (pdb_field + 1), sVIS_SUFFIX, pstr);
  strcat(pcmd, sbuf);

  return;
}
Reply With Quote
  #2 (permalink)  
Old 11-17-06, 15:52
niczak niczak is offline
Registered User
 
Join Date: Nov 2006
Posts: 6
Figured it out, close thread.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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