Skip to main content

Posts

AngularJS interview questions - Part 3

Q21. What is Angular Expression? Ans: Angular expressions are JavaScript-like code snippets that are usually placed in bindings such as {{ expression }} . For example, these are valid expressions in Angular: {{ 3+4 }} {{ a+b }} {{ user.name }} {{ items[index] }} Demo Q22. How Angular expressions are different from JavaScript expressions? Ans: Angular expressions are like JavaScript expressions but there are few differences.   Context : In Angular, the expressions are evaluated against a scope object, while the JavaScript expressions are evaluated against the global window object. Forgiving: In Angular expression evaluation is forgiving to null and undefined, while in JavaScript undefined properties generates TypeError or ReferenceError. No Control Flow Statements: Loops, conditionals or exceptions cannot be used in an Angular expression. No Comma And Void Operators: You cannot use , (comma) or void in an Angular exp

Simple PHP function to update data in Mysql Database

The below simple php function is used to update data into MySql database with out manually filling the update mysql query with input filed names. Function: function update_Defined($table, $data, $condition){     // update('table', array_map('trim',$_POST),'id='.$_POST['p_id']);     global $db;     $query = "UPDATE `" . $table . "` SET ";     $fis = array(); $vas = array();        foreach ($data as $field => $val){         $fis[] = "`$field`";         $vas[] = "'" . mysqli_real_escape_string($db,$val) . "'";     }        foreach ($fis as $key => $field_name) {         $fields[$key] = $field_name;         if (isset($vas[$key])) {             $fields[$key] .= '=' . $vas[$key];         }     }        $query .= implode(',', $fields);     $query .= " WHERE " . $condition;     //echo $query;exit;     Query($query); } Form: <form action="" method=

Simple Function to Insert data into MySql database using PHP

The below simple php function is used to insert data into MySql database with out manually filling the insert mysql query with input filed names. Function: function insert_Defined($table, $array,$ins=''){   // insert('table', array_map('trim',$_POST));     global $db;     $query = "INSERT INTO" . ' ' . $table;     $fis = array(); $vas = array();         foreach ($array as $field => $val) {         $fis[] = "`$field`";         $vas[] = ($val != "NOW()") ? "'" . mysqli_real_escape_string($db,$val) . "'" : "NOW()";     }         $query .= "(" . implode(",", $fis) . ") VALUES (" . implode(",", $vas) . ")";     //echo $query;exit;     Query($query);if(!empty($ins)){$ins_id=mysqli_insert_id($db);return $ins_id;} } Form: <form action="" method="post" name="designation&