This is a common thing that usually required for back end programming. Sometimes we need all rows of a table as an query statement just like – INSERT INTO MyTable(ID,Col1,Col2,Col3) VALUES (100,’some vlaue’,’some value’,’2018-10-20′); So the question is “How do we get the insert query statement for this easily ?” Here I am gonna write a simple PHP function by that you can get the insert query statement for all rows in a table :- <?php function makeInsertQuery($mysqli,$table, $where=null) { $sql=”SELECT * FROM `{$table}`”.(is_null($where) ? “” : ” WHERE “.$where).”;”;…
Year: 2018
MySQL Group By Day, Month Or Year
Most frequently occurred problem that is faced by developers. Here I am gonna explain you for the query Group by Day, Month or Year in MySQL. Using the DATE_FORMAT operator, you can easily group the timestamp, date or datetime column using any format you want. For example, I needed to group rows that were added on the same day. Here is my query: select count(*), DATE_FORMAT(created_at,”%Y-%m-%d”) as created_day FROM widgets GROUP BY DATE_FORMAT(created_at,”%Y-%m-%d”) This query will give you result like this : count(*) | created_day 126 | 2012-04-12 168 |…
How To Setup Cron Job on AWS
Cron job is a process to run a page automatically in background without interrupting user. You can execute a page automatically at any time on daily basis by setting up a cron job. I have already explained about setting up a cron job on godaddy server in one of my article. So now here I am going to explain a step by step process for setting up cron job in AWS too for ubuntu users. Process to Setting Up AWS Cron:- Step #1. Login to your AWS instance through Terminal by…
Top PHP7 Interview Questions And Answers for Freshers & Experienced
This article shows up top frequently asked PHP7 interview questions and answers for PHP Developers, This list of PHP interview questions and answers will be helpful for PHP programmers. Question #1 – How array_walk function works in PHP? It is used to update the elements/index of original array. How: in array_walk, two parameter are required. original array An callback function, with use of we update the array. Question #2 – How to achieve Multilevel inheritance in PHP7? //base class class a{} //parent class extend the base class class bextends a{} //chid…
PHP Program To Find Odd Even Number
“Find odd even number ” is the basic PHP program for a PHP learner. As you all aware, Odd numbers are not divisible by 2 and Even numbers are divisible by 2. Example : Odd number: 3, 5, 7, 9,11 Even number: 2, 4, 6, 8, 10 So here I am gonna explain it with a simple PHP program. Odd Even Number Program :- <?php $number=22; if($number%2==0) { echo “22 is an even number”; } else { echo “22 is not odd number”; } ?> Output…
Swap Two Number Program In PHP
Swap two number generally is the process of interchange two variables with each other. Just suppose you have X whose value 10 there is another number Y with value of 20. Now if we swap these two number with each other then the X value will change to 20 and Y value will change to 10. So here I am gonna explain with a simple PHP program. Swap Two Number Program :- <?php $x=10; $y=20; echo “Value of x: $x</br>”; echo “Value of y: $y</br>”; $temp=$x; $x=$y; $y=$temp; echo “Value of x:…
Armstrong Number Program in PHP
“Armstrong Number Program” is the initial program from where most of the beginner developers will start to learn and write code in any language. An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits is equal to the number itself. Here is an example of check a armstrong number in PHP. Armstrong Number Program :- Below is the simple PHP program to check a number armstrong. <?php $number=153; $sum=0; $temp=$number; while($temp!=0) { $reminder=$temp%10; $sum=$sum+$reminder*$reminder*$reminder; $temp=$temp/10; } if($number==$sum) { echo “It…
Process to Install Docker on Ubuntu 16.04
Docker :- Docker is a container management service. The keywords of Docker are develop, ship and run anywhere. The whole idea of Docker is for developers to easily develop applications, ship them into containers which can then be deployed at anyplace. Docker has two flavors : Community Edition (CE) Enterprise Edition (EE) So if you don’t know which one should be install, just pick up The Community Edition (CE) flavor and install as below Docker Installation :- Follow the step by step process – Step#1 :- Set up the docker repository $ sudo…
What is Docker and Why We Use ?
What is docker ? Docker is a container management service. The keywords of Docker are develop, ship and run anywhere. The whole idea of Docker is for developers to easily develop applications, ship them into containers which can then be deployed at anyplace. Docker has two flavors : The Community Edition (CE) and the Enterprise Edition (EE) Initial Release : March 2013 Mostly use on agile based project. Reference Why docker ? Docker has the ability to reduce the size of development by providing a smaller footprint of the operating system via containers.…
How To Set Custom Variables With DataLayer in GoogleTag manager (GTM) ?
The most common challenge with Google Tag Manager (GTM) is setting up custom variables with dataLayer and making them dynamic for your JavaScript tag. In this article, I will explain the process for setting up custom variables for your custom JavaScript tag. I have previously covered an overview of GTM in another article. You can read it here. Setting Up Custom Variables With dataLayer To set up custom variables with dataLayer, developers need to pass the variables from their code. For example, suppose your JavaScript SDK requires data such as…
