Set cronjob using command line /ssh/ putty

1. Login with your credential using putty.
2. Execute command crontab -e (It will list the the cron jobs)
3. To make it editable, you should press the “insert” button on your keyboard.
4. # MIN HOUR MDAY MON DOW COMMAND
*/1 * * * * curl http://mydomain.com/myphp_script.php

MIN – Minute 0-60
HOUR – Hour [24-hour clock] 0-23
MDAY – Day of Month 1-31
MON – Month 1-12 OR jan,feb,mar,apr…
DOW – Day Of Week 0-6 OR sun,mon,tue,wed,thu,fri,sat
COMMAND – Command to be run Any valid command-line

5. After you’re done editing, press the “Esc” key on your keyboard to exit from the edit mode.

6. To exit cron tab, you should type: :wq and press enter.

Jquery Datatable

DataTables is a table enhancing plug-in for the jQuery Javascript library, adding sorting, paging and filtering abilities to plain HTML tables with minimal effort. The stated goal of DataTables is:

<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css”&gt;
</head>
<body>
<table id=”example”>
<thead>
<tr><th>Sites</th></tr>
</thead>
<tbody>
<tr><td>SitePoint</td></tr>
<tr><td>Learnable</td></tr>
<tr><td>Flippa</td></tr>
</tbody>
</table>
http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js
http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js

$(function(){
$(“#example”).dataTable();
})

</body>
</html>

Load data while scrolling down using ajax and php

$servername = “localhost”;
$username = “root”;
$password = “Oneclick1@”;

$conn = mysql_connect($servername, $username, $password);

// Check connection
if (!$conn) {
die(“Connection failed: ” . mysqli_connect_error());
}
@mysql_select_db(‘test’) or die( “Unable to select database”);
//echo “Connected successfully”;

$select = “select * from user order by id asc limit 0,13”;
$response = mysql_query($select);

while($row = mysql_fetch_assoc($response)){

$data [] = $row;
}

https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js

document.addEventListener(‘scroll’, function (event) {
if (document.body.scrollHeight == document.body.scrollTop + window.innerHeight) {
alert(“Loading More Data”);
loadmore();
}
});

function loadmore(){

var id = $(“div:last”).attr(‘id’);
$.ajax({
type: “POST”,
url: “ajax.php”,
data: {id:id},
cache: false,
success: function(data){
$(“#data”).append(data);
}
});
}

<div id="” style=”border:2px solid gray;”>

=================================================================================================
Ajax.php

$id = $_POST[‘id’];
$total = 13;

$servername = “localhost”;
$username = “root”;
$password = “Oneclick1@”;

$conn = mysql_connect($servername, $username, $password);

// Check connection
if (!$conn) {
die(“Connection failed: ” . mysqli_connect_error());
}
@mysql_select_db(‘test’) or die( “Unable to select database”);
//echo “Connected successfully”;

$select = “select * from user order by id asc limit $id,$total”;
$response = mysql_query($select);

while($row = mysql_fetch_assoc($response)){

$data [] = $row;

}

$res = “”;
foreach($data as $d){

$res .= ‘

‘;
$res .= ‘

‘.$d[‘id’].’

‘;
$res .= ‘

‘.$d[‘name’].’

‘;
$res .= ‘

‘;

}
print_r($res);
exit;

Php rewrite enabled steps

1) install this command : sudo a2enmod rewrite
2) add one directory block in
-> open this location /etc/apache2/sites-enabled/
-> you can see 000-default.conf file and open in vi editor
-> add this block in it

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

-> restart apache : service apache2 restart

By Pratik Patel

Convert Hex Color to RGB using PHP

function hex2rgb($hex) {
$hex = str_replace(“#”, “”, $hex);

if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
$rgb = array($r, $g, $b);
//return implode(“,”, $rgb); // returns the rgb values separated by commas
return $rgb; // returns an array with the rgb values
}

AJAX

Ajax

AJAX = Asynchronous JavaScript and XML.

AJAX is the art of exchanging data with a server, and update parts of a web page – without reloading the whole page.

You can call function that contain AJAX on any event as:- onclick, onsubmit etc. of the form or button.

As:- Change Content

Syntax of AJAX in any function is : –

function anyname() {
$.ajax({
type: “POST”,
url: webURL + “path”,
data: “variable=”+value,
success: function(msg)
{
if(msg!=”)
{——–}
}
});
}

//path is :-path of controller and its function you want to call for processing .
// variable :-parameters you want to sent .
// msg :- after return from controller ‘msg’ contain values that controller return.