Download CSV

if(isset($_REQUEST['downloadCsv']) && $_REQUEST['downloadCsv'] !=""){
	ob_clean();	
	$filename 	= "myFile.csv";
	header('Content-type: application/csv');
	header('Content-Disposition: attachment; filename='.$filename);
	echo $output;
	exit;	
}

Blog zip file with code

`

//////////////////////////// HTML ///////////////////////////////////////
<a title="Recent Blogs" id="recent_blogs" href="#">Our Recent Blogs</a>  
	<div id="recent_blogs_div">
			<? include("recent_blogs.inc.php");?>
	</div>
//////////////// java script ////////////////////////////////////////////
$(document).ready(function() {
	$('#recent_blogs').click(function() {
		//$('#recent_blogs_div').slideToggle();
		if ($('#recent_blogs_div').is(":visible")){
			$('#recent_blogs_div').slideUp(400);
		}else{
			$('#recent_blogs_div').slideDown(400);
		}
		return false;
	});
	$('#close_blog').click(function() {
		if ($('#recent_blogs_div').is(":visible")){
			$('#recent_blogs_div').slideUp(400);
		}else{
			$('#recent_blogs_div').slideDown(400);
		}
	});
});

`
blog

Slide Up Slide Down

`

//////////////////////////// HTML ///////////////////////////////////////
<a title="Recent Blogs" id="recent_blogs" href="#">Our Recent Blogs</a>  
	<div id="recent_blogs_div">
			<? include("recent_blogs.inc.php");?>
	</div>
//////////////// java script ////////////////////////////////////////////
$(document).ready(function() {
	$('#recent_blogs').click(function() {
		if ($('#recent_blogs_div').is(":visible")){
			$('#recent_blogs_div').slideUp(400);
		}else{
			$('#recent_blogs_div').slideDown(400);
		}
		return false;
	});
});

`

Use PHP to create, edit and delete crontab jobs?

Below is the code to create cronjob on a server
`

usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting user's crontab)


<?
$output = shell_exec('crontab -l');
file_put_contents('/tmp/crontab.txt', $output.'* * * * * NEW_CRON'.PHP_EOL);
echo exec('crontab /tmp/crontab.txt');
?>

`

Latest date format (British) or (General)

`

//For Insert in date base--
$valid_from = ($_REQUEST['valid_from'] == '') ? '' : StringUtility::setFormatedDateBritish($_REQUEST['valid_from']);

//For view in textfield--
value="<?php ?echo ($valid_from == '') ? '' : StringUtility::getFormatedDateBritish($valid_from); ?>"

//if date format is simple then use?getFormatedDate instead of?getFormatedDateBritish

`

odd even tr color

$j = 0;
foreach ($student_notes as $i => $value) {
$j = ($j == 0) ? 1 : 0;
$bg_color = ($j == 0) ? “” : “bgcolor=’#f5f5f5′”;
$updatedBy = Admin::getAdminUserById($value[‘updated_by’]);
?>
<tr <?php echo $bg_color; ?>>