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;
}