Posts Tagged "php"

Get last order of an customer magento

Here is the example code by which you can get last order details into mangento of using email id. $_customer = Mage::getModel('customer/customer'); $_customer->loadByEmail('demo@demo.com'); $orders = Mage::getResourceModel('sales/order_collection') ->addFieldToSelect('*') ->addFieldToFilter('customer_id', $_customer->getId()) ->addAttributeToSort('created_at', 'DESC') ->setPageSize(1); <strong>ID</strong> echo $orders->getFirstItem()->getId();…

Like to share it
Read More

How you can add Cron Job at Cpanel?

Execute Cron Job in Cpanel using PHP script. In cpanel the following will also work: Execute code every minute(Server Time) using following code: * * * * * php -q /home/serverpath/file.php Execute code every five…

Like to share it
Read More

How to export the data from MySQL into a XML file with PHP?

There are a couple of ways to export data from MySQL to a XML file. This post looks at how to export the data from MySQL into a XML file with PHP. The example code…

Like to share it
Read More

How to export the data from MySQL into a CSV file with PHP including a header row?

There are a couple of ways to export data from MySQL to a CSV file but some of them never supports adding a header row to the CSV which contains the column names. This post…

Like to share it
Read More

Capitalize the sentence in Javascript!

Capitalize the sentence in Javascript! <script type="text/javascript" language="javascript">// <![CDATA[ String.prototype.capitalize = function(){ return this.replace( /(^|s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); }; function capWords() { var inputString = document.form1.instring; // The input text field var…

Like to share it
Read More

How to add custom post type in wordpress

Open “function.php” add the following code to add new custom post type : <?php add_action(‘init’, ‘featured_post_register’); function featured_post_register() { $labels = array( ‘name’ => _x(‘Featured Posts’, ‘post type general name’), ‘singular_name’ => _x(‘Featured Posts’, ‘post…

Like to share it
Read More

301 redirect with htaccess

How to redirect web based page with .htaccess Following are the code to paste (be careful to write on .htaccess it can be messed up whole website if anything goes wrong) into .htaccess file 301…

Like to share it
Read More

Default page name for technology used in Internet

Following are the detault pages for website of technology based : 1) HTML Based default pages : a) index.htm b) index.html c) default.htm 2) PHP Based default pages : a) index.php 3) SHTML Based default…

Like to share it
Read More

Get the First Monday of the current Month or Get Last Day of Month or Get First Day of Month

Get the First Monday of the current Month or Get Last Day of Month or Get First Day of Month Get the First Monday of the current Month <?php function getFirstMonday($month,$year) { $num = date(“w”,mktime(0,0,0,$month,1,$year));…

Like to share it
Read More

Get file name and remove file extension using php

Get a File name from url Using PHP Get the “filename”, or the last part of the string, with the basename function. <?php $url = ‘http://www.example.com/feeds/xyz/index.php?filename=abc’; echo basename($url); // print “index.php”; ?> Remove a File…

Like to share it
Read More