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”);

}

if (isset({ds[0][0]})) // Row found
{
$myTestField = {rs[0][0]};
}
else // No row found
{
$myTestField = {rs[0][0]};
}

Bernardo:

try this


$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]} == 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

it works!! thank you very much for your help Kafecadm

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

glad it worked.

Regards