Announcement

Collapse
No announcement yet.

Set field value based on sql statement

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

  • Set field value based on sql statement

    I have this sql statement which produces the desired results,
    Code:
    SELECT COUNT(DISTINCT OEMCode) FROM master_data
    WHERE repDate = '2013-04-01'
    I wish to popular a checkbox field based on the results using an if statement at the "on Load" stage I think, so what Im trying to achieve is something like:
    PHP Code:
    if ($sql>>=1)
         {
        {
    newcheckboxfield} = 1;    
        } 
    else
        {
        {
    newcheckboxfield} = 0;
        } 
    I cant seem to put the 2 together or find a similar example? any help appreciated.
    Thanks

  • #2
    In the right section of your event php edit code there's a code snippet to select data from a sql statement. It will give you the result in an array like $rv[0][0]. You change the sql statement to your need and apply your code.

    So you will get something like:
    Code:
    .. your code snippet for selecting data
    if (isset($rv[0][0])) {
      if ($rv[0][0]>1) 
      {
       {newcheckboxfield} = 1;     
      }
      else
      {
        {newcheckboxfield} = 0;     
      }
    }
    That should do it, provided that you have configured your checkbox to respond to 1 and 0 (not Y and N)
    Last edited by aducom; 06-26-2013, 08:46 PM.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Hello,

      Please take a look at our sc_lookup macro: downloads.scriptcase.com.br/downloads/v7/manual/en_us/webhelp/manual_mp/28-Macros/00-macros_sc.htm#sc_lookup

      regards,
      Bernhard Bernsmann

      Comment


      • #4
        Thank you aducom & bartho for your replies, I will be back on this later. However your time is appreciated. I need to check my approach as I may be going about this in the wrong way. See here

        Comment

        Working...
        X