Wednesday 24 April 2013

copy a file into another folder in asp .net

string targetFolder = Server.MapPath(“~/PDF”);
System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(“~/Bookmark.pdf”));
fi.CopyTo(System.IO.Path.Combine(targetFolder, fi.Name), true);

get product thumb images on view.phtml

<!–?<?php $_images = Mage::getModel(‘catalog/product’)->load($_product->getId())->getMediaGalleryImages(); ?>
<?php if($_images){?>
<?php $i=0; foreach($_images as $_image){ $i++; ?>
<a href=”#” onclick=”ig_lightbox_show(-1)”>

<img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘thumbnail’, $_image->getFile())->resize(108,90); ?>” alt=”<?php echo $this->htmlEscape($_image->getLabel());?>” title=”<?php $this->htmlEscape($_image->getLabel());?>” />
</a><?php } ?> <?php } ?>

how to check canvas is empty or not

<canvas id="canvas11″ height=”200px” width=”200px”>
<asp:Button runat=”server” ID=”btn1″ Text=”Save”  OnClientClick=”checkcanvas();” />
<script type=”text/javascript”>
function checkcanvas() {
var i = isCanvasTransparent();
//i =true    if canvas empty
//i =false       if canvas has image
}
function isCanvasTransparent() {
var canvas1 = document.getElementById(‘canvas11′);
// true if all pixels Alpha equals to zero
var ctx = canvas1.getContext(“2d”);
var result;
var imageData = ctx.getImageData(0, 0, canvas1.offsetWidth, canvas1.offsetHeight);
for (var i = 0; i < imageData.data.length; i += 4)
if (imageData.data[i + 3] !== 0) return false;
return true;
}
</script>

countdown timer in php,

$dateFormat = “d F Y — g:i a”;
$targetDate = $futureDate;//Change the 25 to however many minutes you want to countdown change date in strtotime
$actualDate = $date1;
$secondsDiff = $targetDate – $actualDate;
$remainingDay     = floor($secondsDiff/60/60/24);
$remainingHour    = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
$remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
$remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
$actualDateDisplay = date($dateFormat,$actualDate);
$targetDateDisplay = date($dateFormat,$targetDate);
<script type=”text/javascript”>
var days = <?php echo $remainingDay; ?>
var hours = <?php echo $remainingHour; ?>
var minutes = <?php echo $remainingMinutes; ?>
var seconds = <?php echo $remainingSeconds; ?>
function setCountDown(statusfun)
{//alert(seconds);
var SD;
if(days >= 0 && minutes >= 0){
var dataReturn =  jQuery.ajax({
type: “GET”,
url: “<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).’index.php/countdowncont/’; ?>”,
async: true,
success: function(data){
var data = data.split(“/”);
day =  data[0];
hours =  data[1];
minutes =  data[2];
seconds =  data[3];
}
});
seconds–;
if (seconds < 0){
minutes–;
seconds = 59
}
if (minutes < 0){
hours–;
minutes = 59
}
if (hours < 0){
days–;
hours = 23
}
document.getElementById(“remain”).style.display = “block”;
document.getElementById(“remain”).innerHTML = ” Your Product Reverse For “+minutes+” minutes, “+seconds+” seconds”;
SD=window.setTimeout( “setCountDown()”, 1000 );
}else{
document.getElementById(“remain”).innerHTML = “”;
seconds = “00″; window.clearTimeout(SD);
jQuery.ajax({
type: “GET”,
url: “<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).’index.php/countdown/’; ?>”,
async: false,
success: function(html){
}
});
document.getElementById(“remain”).innerHTML = “”;
window.location = document.URL; // Add your redirect url
}
}
</script>
<?php
if($date1 < $futureDate &&  ($qtyCart > 0)){ ?>
<script type=”text/javascript”>
setCountDown();
</script>
<?php }else{ ?>
<style>
#remain{display:none;}
</style>
<?php }}?>
<div id=”remain”></div>

some mysql queries

1. Add column age and desg in emp_prof table.
Mysql> use profile;
Mysql>alter table emp_prof add column age int;
Mysql> alter table emp_prof add column desg char(10);

2. Update all records of emp_prof.(desg= actn,officer)
Mysql> use profile;
Mysql>update emp_prof set age=24,desg=’officer’ where emp_id=101;
Mysql>update emp_prof set age=21,desg=’actn’ where emp_id=102;
(follow above queries for other records)

3. Display all records from emp_prof where age is 24 and designation is actn.
Mysql> use profile;
Mysql>select * from emp_prof where age=24 and desg=’actn’;

4. Display all records from emp_prof where age is 24 or designation is actn.
Mysql> use profile;
Mysql>select * from emp_prof where age=24 or desg=’actn’;

5.Display emp_name and age where age is not below 25
Mysql> use profile;
Mysql>select emp_name from emp_prof where not age<25;

6.Display emp_name and age where age between 21 and 25
Mysql> use profile;
Mysql> select emp_name from emp_prof where age between 21 and 25;

7.Display name and age where age is not between 23 and 26.
Mysql> use profile;
Mysql>select emp_name from emp_prof where not age between 23 and 26;

8.Display emp_name and country where reperesenting country (‘india’,’australia’)
Mysql> use profile;
Mysql>select emp_name,country from emp_prof where country in (‘india’,’australia’);

9. Display emp_name from emp_prof where emp_name starting with alphabet s.
Mysql> use profile;
Mysql>select emp_name from emp_prof where emp_name like ‘s%’;

10. Display all records from table cust_prof where fname is ending with alphabet s.
Mysql> use profile;
Mysql>select fname from cust_prof where fname like ‘%s’;

11. Display all records from table cust_prof where fname contains alphabet z.
Mysql> use profile;
Mysql>select * from cust_prof where fname like ‘%z%’;

12. Display all records from table cust_prof where lname contains alphabet ‘is’.
Mysql> use profile;
Mysql>select * from cust_prof where lname like ‘%is%’;

13. Display all records from table cust_prof where uppercase ‘A’ is present in fname.
Mysql> use profile;
Mysql>select * from cust_prof where fname like binary ‘%A%’;

  1. Display fname and lname from cust_prof where lowercase ‘t’ is present in fname.
Mysql> use profile;
Mysql>select fname,lname from cust_prof where fname like binary ‘%t%’;

15. Display fname and lname from cust_prof table where 2nd character of fname is ‘a’.(like ‘_a%’)
Mysql> use profile;
Mysql>select fname,lname from cust_prof where fname like  ‘_a%’;

16. Display emp_names from emp_prof  where 2nd last character of the name is ‘e’. (like ‘%e_’)
Mysql> use profile;
Mysql>select emp_name from emp_prof where emp_name like ‘%e_’;


17. Display emp_name from emp_prof where emp_name has exact 5 charecters. ( like ‘_ _ _ _ _ ‘)
Mysql> use profile;
Mysql>select emp_name from emp_prof where emp_name  like ‘_ _ _ _ _’;

18. Display emp_name from emp_prof where name contains ‘s’ first and then ‘i’ somewhere thereafter.
Mysql> use profile;
Mysql>select emp_name from emp_prof where emp_name like ‘s%i%’;

19. Display emp_name from emp_prof where emp_name second character of name is ‘a’ and contains ‘p’ somewhere after thereafter.(like ‘_a%p%’)
Mysql> use profile;
Mysql>select emp_name from emp_prof where emp_name like ‘_a%p%’;

20. Display emp_names from emp_prof where emp_name second character of emp_name is ‘a’ and last character of name is ‘s’. (like ‘_a%s’)
Mysql> use profile;
Mysql>select emp_name from emp_prof where emp_name like ‘_a%s’;

recursive function for getting parent and child

function categoryChild($id) {
$s = “SELECT ID FROM PLD_CATEGORY WHERE PARENT_ID = $id”;
$r = mysql_query($s);
$children = array();
if(mysql_num_rows($r) > 0) {
# It has children, let’s get them.
while($row = mysql_fetch_array($r)) {
# Add the child to the list of children, and get its subchildren
$children[$row['ID']] = categoryChild($row['ID']);
}
}
return $children;
}

quick seo (A SEO guide )

In this guide  you can learn how increase traffic on your site…
Download