Monday, November 25, 2013
Thursday, November 21, 2013
Simple banner rotator with jQuery
<!DOCTYPE html>
<html>
<head>
<!--Included jquery script library-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(window).load(function() {
startRotator("#rotator");
})
//Initialise rotate js
function rotateBanners(elem) {
var active = $(elem+" img.active");
var next = active.next();
if (next.length == 0)
next = $(elem+" img:first");
active.removeClass("active").fadeOut(200);
next.addClass("active").fadeIn(200);
}
function prepareRotator(elem) {
$(elem+" img").fadeOut(0);
$(elem+" img:first").fadeIn(0).addClass("active");
}
function startRotator(elem) {
prepareRotator(elem);
setInterval("rotateBanners('"+elem+"')", 2000);
}
</script>
<!-- Initialise rotate css -->
<style>
#rotator img { position: absolute; }
</style>
</head>
<body>
<!-- Rotator images -->
<div id="rotator">
<img height="154" src="C:\Users\Public\Pictures\Sample Pictures\Autumn Leaves.jpg" width="550" />
<img height="154" src="C:\Users\Public\Pictures\Sample Pictures\Garden.jpg" width="550" />
<img height="154" src="C:\Users\Public\Pictures\Sample Pictures\Green Sea Turtle.jpg" width="550" />
<img height="154" src="C:\Users\Public\Pictures\Sample Pictures\Autumn Leaves.jpg" width="550" />
<img height="154" src="C:\Users\Public\Pictures\Sample Pictures\Garden.jpg" width="550" />
<img height="154" src="C:\Users\Public\Pictures\Sample Pictures\Green Sea Turtle.jpg" width="550" />
</div>
</body>
</html>
Wednesday, October 30, 2013
Generate .csv file using PHP
<?php
// Set label with comma separated
$str='';
$str.="tracking_name,origin_zipcode,destination_zipcode,price,customername,orderid,
alt_email_id";
$str .="\n";
// Set value with comma separated
$str .="BR76646474RT,5874,2564,150,jaoun brend,ID6353653,admin@admin.com";
$str .="\n";
$str .="BR76646474RT,5874,2564,150,jaoun brend,ID6353653,admin@admin.com";
// Set header for download file
header("Expires: 0");
header("Cache-control: private");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.ms-excel");
header("Content-type: text/x-csv");
header("Content-Disposition: attachment; filename=rastreamento_detalhado.csv");
print $str;
exit;
?>
Tuesday, October 22, 2013
Resize image using PHP
<?php
// Include the class
include("resize-class.php");
// 1) Initialise / load image
$resizeObj = new resize('sample.jpg');
// 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> resizeImage(200, 200, 'crop');
// 3) Save image
$resizeObj -> saveImage('sample-resized.jpg', 100);
?>
Thursday, October 17, 2013
Upload multiple image in PHP
<html>
<head>
<title>Multi Image Upload</title>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script type="text/javascript">
var i=1;
function fnaddimage(){
if(i<5){
$('#check').before('<div id="addimage"><div class="select-image"><input type="file" name="image[]"></div><input type="button" value="Remove" onclick="fnremoveimage(this)"></div></div>');
i++;
}
}
function fnremoveimage(intI){
$(intI).parent().remove();
i--;
}
</script>
<style>
.select-image{float:left}
</style>
</head>
<body>
<?php
if(!empty($_POST)){
for($i=0;$i<count($_FILES["image"]["name"]);$i++){
$fileData = pathinfo(basename($_FILES["image"]["name"][$i]));
if($fileData['extension']=='jpg' || $fileData['extension']=='png' || $fileData['extension']=='gif' || $fileData['extension']=='jpeg'){
$target_path = $_SERVER['DOCUMENT_ROOT'].'upload/'.$fileData['basename'];
move_uploaded_file($_FILES["image"]["tmp_name"][$i], $target_path);
}
else
{
echo "There was an error uploading the file {$_FILES['image']['name'][$i]}, please try again!<br />";
}
}
}
?>
<form enctype="multipart/form-data" action="multiimage.php" method="POST">
<div>
<div id="addimage">
<div class="select-image"><input type="file" name="image[]"></div>
<div class="btn-image">
<input type="button" value="Add" onclick="fnaddimage()">
</div>
</div>
<div id="check"></div>
<input type="submit" name="Upload" value="Upload">
</div>
</form>
</body>
</html>
Tuesday, October 8, 2013
Flash Player Timer
<html>
<head>
<title>Flash Timer</title>
</head>
<body>
<object align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" height="180" id="main" width="176">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="http://beta.theonepoint.net/public/images/hquiz/main.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<param name="FlashVars" value="sec=60&id=2" />
<embed src="http://beta.theonepoint.net/public/images/hquiz/main.swf"
width="176"
height="180"
autostart="false"
quality="high"
bgcolor="#ffffff"
FlashVars="sec=60&id=2"
name="main"
align="middle"
wmode="transparent"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
Wednesday, October 2, 2013
Get Days,Months,Years,Hours,Minutes and Seconds between Dates in PHP
<?php
// First Date
$exp_date = date("Y-m-d",strtotime('2013-09-24 16:20:00'));
//Second Date
$del_date = date("Y-m-d",strtotime('2013-09-30 11:54:47'));
$datetime1 = date_create($exp_date);
$datetime2 = date_create($del_date);
$interval = date_diff($datetime1, $datetime2);
//Display all parameters with value
print "<pre>";
print_r($interval);
?>
Subscribe to:
Posts (Atom)