Posts

Showing posts from 2017

Perform airthmatic operation in select sql query when airthmatic operator stored in database

id a b operation c 1 2 3 + 5 2 2 3 + 6 3 3 2 / 1 4 4 7 * 28 5 54 2 - 27 6 3 0 / 0 Using operation in fetching the value select  case                     when operation='+' then a+b                    when operation='-' then a-b                     when operation='*' then a*b                    when operation='/' then a/b            END  from table ; Using in where  condition while checking the value with c if airthmatic operation is equal to the the value in c coloum    select * from expressions where c= case when operation='+' then a+b                                     when operation='-' then a-b  when operation='*' then a*b when operation='/' then a/b END 

show month name from month number value

$m=monthnumber(like 1 OR 2 OR 3 OR 4)); return $m % 13 ? date(M, $m * 25e5) : 'invalid month'; 

Algorithm that will check whether the given grid of numbers represents a valid Sudoku puzzle In PHP

Sudoku  is a number-placement puzzle. The objective is to fill a  9 × 9  grid with numbers in such a way that each column, each row, and each of the nine  3 × 3  sub-grids that compose the grid  all  contain  all  of the numbers from  1  to  9  one time. Implement an algorithm that will check whether the given  grid  of numbers represents a valid  Sudoku  puzzle according to the layout rules described above. Note that the puzzle represented by  grid  does not have to be solvable. <?php function sudoku2($grid) {    $n=count($grid);    $m=count($grid[0]);    if($n==$m)    {        $status=true;        foreach($grid as $key=>$gridDetail)        {            $gridDetail=str_replace (".","",$gridDetail);            $gridDetail=array_filter($gridDetail);                     foreach($gridDetail as $keydetail=>$gridInfo)           {               $arrayindex=checkdetail($key,$keydetail);                           i

Remove gitignored file from tracking

The series of commands below will remove all of the items from the Git Index (not from the working directory or local repo), and then updates the Git Index, while respecting git ignores. PS. Index = Cache First: git rm -r --cached . git add . Then: git commit -am "Remove ignored files"

checking coloumName value before update. if value of coloumName = 1 then 0,if coloumName = 0 then 1.

UPDATE `tableName ` SET ` couloumName `= IF (coloumName = 1 , 0 , 1 ) WHERE id = Idvalue