Skip to main content

Posts

Showing posts from April, 2018

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&

Calculate Number of working days in a month excluding weekends(Saturday and Sunday) using PHP

The below function is used to calculate number of working days in a month. Function Calling: $no_days= rns_countDays ($row['date'],array(0, 6)); Function: function rns_countDays($date, $ignore) {      //echo countDays(array(0, 6), start_date, end_date);     $count = 0;     $ndays=0;     $now=date("Y-m-d");     $month=date("m",strtotime($date));     $year=date("y",strtotime($date));            if($month==date("m") && $year==date('y')) { //Date diff month start date to current date         $from_date = new DateTime($year.'-'.$month.'-01');         $to_date = new DateTime($now);         $days_diff=$from_date->diff($to_date); //echo $days_diff->d;         $ndays=$days_diff->format("%a");         for($i=0;$i<$ndays;$i++){             $modif = $from_date->modify('+1 day');             $weekday = $from_date->format('w');             if(in_array($weekday, $igno

Split Text into Lines - SplitLines | Free jQuery Plugins

SplitLines is a lightweight jQuery plugin which allow you to split  block of text into  multiple lines using specific html tag(s) and defined width & line height .  SplitLines ( $.splitLines() ) is a jQuery plugin that splits new lines of wrapped text into their own HTML elements, allowing you to animate or operate on each line individually. Works with nested HTML tags as well. splitLines() takes a block of text and splits it up into separate lines based on the width of the box or a width passed to the function. Requirements jQuery 1.4.2 or later How to Split Text By Lines Include required libraries on page. <script src="//code.jquery.com/jquery.min.js"></script> <script src="jquery.splitlines.js"></script> HTML: Below is the sample text which need to split into lines. <div id="mycontent">     This is an <strong>example</strong> of some long text     that we want to split into lines. </div>   Jav

Beautiful Checkbox CSS - Custom Checkboxes using CSS

Today we are going to share awesome lightweight CSS plugin to beautify the default checkboxes. The beautiful-checkbox.css library allows you to beautify and change styles, sizes, and positions of the native checkbox inputs with pure CSS.