pascal-step4

How to Make Pascal Triangle in PHP

A few days ago, my friend asked me how to make pascal triangle in PHP. Then, I start coding to make it. And now, I want to share my code with you. Hope this post will help you to solve your problem in pascal triangle with PHP.

Before start, I will inform you that this tutorial will divided to be 4 parts, thats:

  1. Make the number to show in an array and show it also in array,
  2. Show the number with table in left alignment,
  3. Show the number with table in right alignment,
  4. And, show the number with table in center alignment

Our goal is make pascal triangle like this picture below Continue reading

Math Captcha

Make Math Captcha in PHP

Math Captcha

Hello guys! How are you? I hope you are fine. In this post, I want to share how to make your own math captcha in PHP. But before we write the code, I want to explain what is captcha.

CAPTCHA (Completely Automated Public Turing Test To Tell Computers and Humans Apart) was first used in 2000 by Luis von Ahn, Nicholas Hopper, Manuel Blum, and John Langford of Carnegie Mellon University. They developed the first captcha to be used by Yahoo. In my own words, captcha is a program or code that use in a website to protect their form from SPAMMER.

Continue reading

dcomparison-product
FransesCorner home
iklanrandom
wordpress pagination ilustration

How to Make WordPress Pagination Without Plugin

wordpress pagination ilustration
By default, wordpress CMS only bundled with the “next page” or “previous page” navigation link to linked one page with the other. I think if you use the other navigation such as numeric navigation for you blog, it will be better than just use the bundled link.

There are two options to make the numeric navigation. First, by using a wordpress plugin from third party and the second is adding your own code in wordpress themes. On this post I will try to share the second one, how to make wordpress pagination without plugin.

1. First step, add this code below to your functions.php

function pagination($pages = '', $range = 2){
	global $paged;
	if(empty($paged)) $paged = 1;

	if($pages == ''){
		global $wp_query;
		$pages = $wp_query->max_num_pages;
		if(!$pages){
			$pages = 1;
		}
	}   
	
	//if available more than one page
	if($pages > 1){
		//start div
		$return = "<div id='pagination'><span id='paged'>Page $paged of $pages</span>";
		
		//set limit before/previous
		$limit_before = ($paged - $range);
		if($limit_before < 1) $limit_before = 1;
		
		//set limit after
		$limit_after = ($paged + $range);
		if($limit_after > $pages) $limit_after = $pages;
		
		//show First page
		if($paged > 2 AND $limit_before!= 1) $return .= "<a href='".get_pagenum_link(1)."'>&laquo;</a>";
		
		//show Previous page
		if($paged > 1) $return .= "<a href='".get_pagenum_link($paged-1)."'>&lsaquo;</a>";
		
		//show number of pages
		for($i = $limit_before; $i <= $limit_after; $i++){
			if($i == $paged){
				$return .= "<span id='paged'>$i</span>";
			}else{
				$return .= "<a href='".get_pagenum_link($i)."'>$i</a>";
			}
		}
		
		//show Next page
		if($paged < $pages) $return .= "<a href='".get_pagenum_link($paged+1)."'>&rsaquo;</a>";
		
		//show Last page
		if($paged < ($pages-1) AND $limit_after != $pages) $return .= "<a href='".get_pagenum_link($pages)."'>&raquo;</a>";
		
		//end div
		$return .= "</div>";
	}
	
	return $return;
}

2. Then, call the pagination function in your template file by add this code below

<?php echo pagination(); ?>

3. The pagination is ready to use now, you can refresh the browser to see the change. But to make it more beautiful, you can add come CSS code in your stylesheet. This is the example CSS style.

#pagination{
    text-align: center;
    margin: 20px 10px 10px 10px;
}

#pagination a{
    margin: 0px 2px 0px 2px;
    padding: 5px 10px 5px 10px;
    -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.5);
    -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.5);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.5);
    font-size: 15px;
    font-weight: bold;
}

#paged, #pagination a:hover{
    margin: 0px 1px 0px 1px;
    padding: 5px 10px 5px 10px;
    color: #ffffff;
    text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.3), 0px 1px 0px rgba(255, 255, 255, 0.3);
    border: 1px solid #0064cd;
    background-color: #049cdb;
    background: -moz-linear-gradient(center bottom, #0064cd, #049cdb);
    background: -webkit-linear-gradient(bottom, #0064cd, #049cdb);

    border-radius: 3px 3px 3px 3px;
    -moz-border-radius: 3px 3px 3px 3px;
    -webkit-border-radius: 3px 3px 3px 3px;

    -webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.15);
    -moz-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.15);
    box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.15); 
}

4. Finish.

This is the result.

Any comment for this post? Don’t hesitate to leave response below.

Thank you.

 

Epson TMU220

Epson TM-U220 Error Not Available

Epson TMU220

A few days ago, I developed a project for a building material store in Bandung. I used Epson TM-U220 as the main printer for cashier thats running in Windows XP. But I had a problem with this printer. When first time I turned on the printer it worked properly and the status was “Ready”, but when I operated it for a few minutes or hours it status would be “Not Available” and I must restart the printer to get it worked properly again. This problem happened very often.

Continue reading