Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006

    Unanswered: 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'.

    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)
      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)
      sprintf(sbuf, "%s%s", pform_field, sVIS_SUFFIX);
      if (((pstr = fWeb_Form_Val(pparms, sbuf)) == NULL) || !strlen(pstr))
      sprintf(sbuf, ",c%s%s='%s'", (pdb_field + 1), sVIS_SUFFIX, pstr);
      strcat(pcmd, sbuf);

  2. #2
    Join Date
    Nov 2006
    Figured it out, close thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts