Tuesday 26 July 2016

Simple Pagination Logic

mysql_connect('localhost','root','');
mysql_select_db('Test');
$perpage=5;
$totalpage=mysql_num_rows(mysql_query('SELECT * FROM pagination'));
$pagination=ceil($totalpage/$perpage);

-------------------------------------------------------------------------------------------------------------------

if(isset($_GET['page']))
{
    $page=$_GET['page'];
}
else
(
    $page=1
);
$startfrom=($page-1)*$perpage;
$fnal_query ='SELECT * FROM pagination LIMIT '.$startfrom.','.$perpage ;
$result=mysql_query($fnal_query);

---------------------------------------------------------------------------------------------------------------------

for($i=1;$i<=$pagination;$i++)
  {?>
    <a href="<?php echo '?page='.$i;?>">
      <?php echo $i; ?>
      </a>
<?php }?>

PHP Image size is less than 1mb

1MB == 1048576 bytes

1MB == 1024 Kbytes

if($_FILES['name']['size'] > 1048576){
  //You can not upload this file
}

 

Wednesday 6 April 2016

Set currency format for textbox on Keyup

Enter the numbers into textbox and textbox would convert automatically these number into currency.(12,345,654)

<script>
 function Comma(Num) { //function to add commas to textboxes
        Num += '';
        Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
        Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
        x = Num.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1))
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        return x1 + x2;
    }
</script>
<input type="text" maxlength="20" class="" id="demo-number-value" value="" onkeyup = "javascript:this.value=Comma(this.value);"/>

Thursday 17 March 2016

Show Dynamic RSS Feed on Your Website

RSS (Really Simple Syndication) feeds offer a method for normal guests of your web site to remain knowing of your most up-to-date content. you'll begin a brand new RSS feed, betting on your website, through such places as Feedburner. guests will then add your RSS feed to their Google Reader or as a appliance on their iGoogle pages. you'll conjointly add your RSS feed to your own website to form an automatic suggests that to showcase your latest content. you'll conjointly use services like HootSuite to push your RSS feed bent on places like Twitter, Facebook and lots of alternative social networking sites.

The purpose of this text is to indicate alternative ways on a way to gift RSS feeds on your website. this could be a really effective thanks to offer recent content to your readers. The content doesn’t even essentially have to be compelled to be your own, you'll use feeds from totally different sites in addition, however it’s best to use relevant content to your website.

header("Content-Type: application/rss+xml; charset=ISO-8859-1");

// Include your normal database connection file
require("connectdb.inc.php");

$sql2 = "SELECT * FROM blog WHERE status = '1' ORDER BY blogID DESC";
$query =mysql_quert($sql2);

$rssfeed = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$rssfeed .= '<rss version="2.0">';
$rssfeed .= '<channel>';
$rssfeed .= '<title>Fashion And Lifestyle Blog By Sonal Agrawal</title>';
$rssfeed .= '<link>http://www.pinkpeppercorn.in</link>';
$rssfeed .= '<description>A fashion and beauty blog that inspires readers to create the perfect wardrobe with essential styling tips by Sonal Agrawal</description>';
$rssfeed .= '<language>en-us</language>';

while($row=mysql_fetch_array($query)){
    $title=$row['blogTitle'];
    $link=$row['seoUri'];
    $description=$row['synopsis'];
  
    $rssfeed .= '<item>';
    $rssfeed .= '<title>' . $title . '</title>';
    $rssfeed .= '<description>' . $description . '</description>';
    $rssfeed .= '<link>http://www.example.in/blog/' . $link . '/'.$row['blogID'].'</link>';
    $rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($row['dateAdded'])) . '</pubDate>';
    $rssfeed .= '</item>';  
}
    $rssfeed .= '</channel>';
    $rssfeed .= '</rss>';

   echo $rssfeed;

Friday 4 March 2016

Get Category and Subcategory Hierarchy From Ebay

You can get the updated category and subcategory list from Ebay !

  • Create the application on http://developer.ebay.com
  • Generate the Appid
  • Copy Appid and paste below
NOTE :-
$url= 'http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=APPID&siteid=203&CategoryID=-1&version=729&IncludeSelector=ChildCategories';
    $sXML = download_page($url);
    $oXML = simplexml_load_string($sXML);
    $cat_id=array();
    foreach($oXML->CategoryArray->Category as $category)
    {
        if($category->CategoryID!="-1")
        {
            $category->CategoryName;
            $category->CategoryID;
        }
    }