Announcement

Collapse
No announcement yet.

Event Macro sc_lookup - some help

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

  • Event Macro sc_lookup - some help

    Pls, I need help with this:

    $sql = "SELECT
    result_answer_points
    FROM results_answers
    WHERE resultid = '{id}'";
    sc_lookup(ds,$sql);
    if (empty({ds})) ( here I need to know if the field "result_answer_points = 0" thank you in advance for helping me)
    {
    {correcion}= "Corregir pdtes.";
    sc_field_color ("coreccion", "#FF0000");

    }
    else
    {
    {correcion}= "Corregir pdtes.";
    sc_field_color ("correccion", "#0D4FCF");

    }

  • #2
    if (isset({ds[0][0]})) // Row found
    {
    $myTestField = {rs[0][0]};
    }
    else // No row found
    {
    $myTestField = {rs[0][0]};
    }
    Giorgio Bravi
    Dolphin Software & Thinkware
    www.dolphin.it

    Comment


    • #3
      Bernardo:

      try this

      PHP Code:
      $sql "SELECT 
      result_answer_points
      FROM results_answers
      WHERE resultid = '{id}'"
      ;
      sc_lookup(ds,$sql);
      if (empty({
      ds})) // here you are asking if you found something in your query in other words if there any resultpoints for the id you are looking for
      {
            {
      correcion}= "Corregir pdtes.";
             
      sc_field_color ("coreccion""#FF0000");
      }
      else 
      // if you found something in your query then you have to evaluate the value of resutl_answer_points
      {
             if ( {
      ds[0][0]} == // as you can see {ds[0][0]} is referencing the actual value of result_answer_points
             
      {
                        
      // do w/e you need here
             
      }
             else
             {
                      
      // do w/e you need here
             
      }


      Hope this helps.

      regards

      Comment


      • #4
        it works!! thank you very much for your help Kafecadm

        Comment


        • #5
          I need some help again pls

          // SQL statement parameters
          $sum_points = "SELECT
          sum(result_answer_points)
          FROM results_answers
          WHERE resultid = '{resultid}'";
          sc_exec_sql($sum_points);

          $update_table = 'results';
          $update_where = "resultid = '{resultid}'";
          $update_fields = array(
          "result_points = ", (Here I need to update de $sum_points but I don't know how to do it)
          );

          // Update record
          $update_sql = 'UPDATE ' . $update_table
          . ' SET ' . implode(', ', $update_fields)
          . ' WHERE ' . $update_where;
          sc_exec_sql($update_sql);

          Comment


          • #6
            Originally posted by Bernardo View Post
            it works!! thank you very much for your help Kafecadm
            glad it worked.

            Regards

            Comment

            Working...
            X