Md. Golam Rabbany

Just work with honesty, Success will come on your door

Category Archives: CodeIgniter Class

Convert Seconds To Hours Minutes Seconds Words


<?php

/**
*
* @convert seconds to hours minutes and seconds
*
* @param int $seconds The number of seconds
*
* @return string
*
*/
function secondsToWords($seconds)
{
/*** return value ***/
$ret = "";

/*** get the hours ***/
$hours = intval(intval($seconds) / 3600);
if($hours > 0)
{
$ret .= "$hours hours ";
}
/*** get the minutes ***/
$minutes = bcmod((intval($seconds) / 60),60);
if($hours > 0 || $minutes > 0)
{
$ret .= "$minutes minutes ";
}

/*** get the seconds ***/
$seconds = bcmod(intval($seconds),60);
$ret .= "$seconds seconds";

return $ret;
}
?>

How to add your Class at CodeIgniter


Step#1: create your own class
<?
class class_name {

function function_name()
{
echo “I am There”;
}

}
?>

Now save this file on your libraries (system->libraries) and file name is must according to your class name like class_name.php

 

Step#2: create a controller like this…
<?php

class own_controller extends Controller {

function own_controller()

{

parent::Controller();

}

function show_text()

{
$this->load->library(class_name);
echo $this-> class_name -> function_name();
}

}
?>

Now save the controller at your controller folder.

OUT PUT will be “I am There”

 

Flash Chart Integrate With CodeIgniter


Requirements:
1. a swf file
2. a helper file
3. a library file
4. a controller

SWF File:
Download the file and past it root folder like http://localhost/your_folder

Helper File:
Download the helper file and past it root folder like http://localhost/your_folder/system/helpers

Library File:
Download the library file and past it root folder like http://localhost/your_folder/system/libraries

Controller File:

create a controller name Welcome and past the code:

<?php

class Welcome extends Controller {

function Welcome()
{
parent::Controller();
}

function index()
{

$this->load->helper(‘flash_chart’);
$this->load->helper(‘url’);
$base_url = site_url(‘Welcome/flash_data’);
open_flash_chart_object( 500, 250, $base_url, false );

}

function flash_data()

{

$this->load->library(‘graph’);
srand((double)microtime()*1000000);

$bar_red = new bar_3d( 75, ‘#D54C78’ );
$bar_red->key( ‘2006’, 10 );

// add random height bars:
for( $i=0; $i<10; $i++ )
$bar_red->data[] = rand(2,5);

//
// create a 2nd set of bars:
//
$bar_blue = new bar_3d( 75, ‘#3334AD’ );
$bar_blue->key( ‘2007’, 10 );

// add random height bars:
for( $i=0; $i<10; $i++ )
$bar_blue->data[] = rand(5,9);

// create the graph object:
$g = new graph();
$g->title( ‘3D Bar Chart’, ‘{font-size:20px; color: #FFFFFF; margin: 5px; background-color: #505050; padding:5px; padding-left: 20px; padding-right: 20px;}’ );

//$g->set_data( $data_1 );
//$g->bar_3D( 75, ‘#D54C78’, ‘2006’, 10 );

//$g->set_data( $data_2 );
//$g->bar_3D( 75, ‘#3334AD’, ‘2007’, 10 );

$g->data_sets[] = $bar_red;
$g->data_sets[] = $bar_blue;

$g->set_x_axis_3d( 12 );
$g->x_axis_colour( ‘#909090’, ‘#ADB5C7’ );
$g->y_axis_colour( ‘#909090’, ‘#ADB5C7’ );

$g->set_x_labels( array( ‘January,February,March,April,May,June,July,August,September,October’ ) );
$g->set_y_max( 10 );
$g->y_label_steps( 5 );
$g->set_y_legend( ‘Open Flash Chart’, 12, ‘#736AFF’ );
echo $g->render();

}

}
?>

Now run your graph : hrrp://loclahost/your_folder/ and out put like this
Grpah Image

if your want to know more about this graph please visit: http://http://teethgrinder.co.uk/open-flash-chart/