Announcement

Collapse
No announcement yet.

Checkbox

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Checkbox

    Hi,

    I have a control form with a checkbox filed on it. The user can select multiple values. How can I update those values using a single query.
    The update query code that Scriptcase provides (show below) doesn't work past the second selected value.

    Code:
    /**
     * Update a record on another table
     */
    
    // SQL statement parameters
    $update_table  = 'my_table';      // Table name
    $update_where  = "databasefield = {checkboxfield}"; // Where clause
    $update_fields = array(   // Field list, add as many as needed
         "field_1 = 'new_value_field_1'",
         "field_2 = 'new_value_field_2'",
     );
    
    // Update record
    $update_sql = 'UPDATE ' . $update_table
        . ' SET '   . implode(', ', $update_fields)
        . ' WHERE ' . $update_where;
    sc_exec_sql($update_sql);
    Any help would mean a lot.

  • #2
    If you have a multiple select then it depends on the way you have defined that field of how the field is returned. In general you bind the field to a varchar of suffiecient length and your data is being stored as ' option1;option2;option10' for instance. So if this field is read for display the right checkboxes will be filled then. You can of course explode these to individual fields and insert them as separate records but then you will not be able to redo your screen but perhaps this is not necessary?
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      In SC I have set the field to checkbox and am using Lookup to populate the values. For example they are:
      112233
      223232
      232334
      454545

      Now on validate I want to update the table (or rows in that table) that contains these numbers only for the selected values. Suppose it is the first and third value. So those rows would be updated....

      I will go over your reply in detail a little later. I think my brain has stopped working
      Last edited by gamer99; 05-21-2014, 03:40 AM.

      Comment


      • #4
        Got it working! I changed the the equal to in where to IN and set the delimiter to comma(,).
        Last edited by gamer99; 05-22-2014, 02:45 AM.

        Comment

        Working...
        X