Ejemplo n.º 1
0
                                             while ($row1 = mysql_fetch_assoc($query1)) {
                                                 $arr = array("label" => $row1['name'], "id" => $row1['id'], "name" => $row1['name'], "type" => $row1['type']);
                                                 array_push($reply, $arr);
                                             }
                                         } else {
                                             if ($type == "solution") {
                                                 $type1 = get_type_id($type);
                                                 $sql1 = "SELECT * FROM pkn_name WHERE (type='{$type1}' AND name LIKE '{$term}') ORDER BY name ASC";
                                                 // lay id name
                                                 $query1 = mysql_query($sql1);
                                                 while ($row1 = mysql_fetch_assoc($query1)) {
                                                     $sql2 = "SELECT * FROM {$table} WHERE name = '{$row1['id']}'";
                                                     // lay id name
                                                     $query2 = mysql_query($sql2);
                                                     while ($row2 = mysql_fetch_assoc($query2)) {
                                                         $arr = array("label" => getname($row2['name']), "id" => $row2['id'], "name" => getname($row2['name']), "units" => get_formula_units($row2['id']), "unitsname" => get_obj_name("pkn_units", get_formula_units($row2['id'])));
                                                         array_push($reply, $arr);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
     } else {
         if ($_SESSION['admin'] == 0) {
             $sql = "INSERT INTO pkn_used (content,weight,user,user_input,time,solution,description) VALUE ('{$data['id']}','{$data['weight']}','{$data['user']}','{$user_id}','{$data['date']}','0','{$data['used']}')";
         }
     }
     if (mysql_query($sql)) {
         array_push($reply, array("result" => "Thêm thành công"));
     } else {
         array_push($reply, array("result" => "Thêm thất bại"));
     }
 }
 if ($data['table'] == "solution" && $data['action'] == "save") {
     $sql1 = "SELECT * FROM pkn_formula WHERE (solution = '{$data['id']}') AND (total = TRUE)";
     $result1 = mysql_query($sql1) or die(mysql_error());
     while ($row1 = mysql_fetch_assoc($result1)) {
         $tmp = array("solution" => $row1['solution'], "name" => get_obj_name("pkn_solution", $row1['solution']), "weight" => $row1['weight']);
         array_push($cal, $tmp);
     }
     // get content / total
     $sql2 = "SELECT * FROM pkn_formula WHERE (solution = '{$data['id']}') AND (total = FALSE)";
     $result2 = mysql_query($sql2) or die(mysql_error());
     while ($row2 = mysql_fetch_assoc($result2)) {
         $tmp = array("solution" => $row2['solution'], "content" => $row2['content'], "weight" => $row2['weight']);
         array_push($cal, $tmp);
     }
     // caculator
     for ($i = 1; $i < sizeof($cal); $i++) {
         $tmpc = array();
         $tmpc['solution'] = $cal[$i]['solution'];
         $tmpc['content'] = $cal[$i]['content'];
         $tmpc['weight'] = $cal[$i]['weight'] * $data['weight'] / $cal[0]['weight'];