Md. Golam Rabbany

Just work with honesty, Success will come on your door

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;
}
?>

Adding Custom Text to an Image


<?
header ("Content-type: image/pjpeg");
$string = "This is sooo cool it works!!!";
$font  = 4;
$width  = ImageFontWidth($font)* strlen($string) ;
$height = ImageFontHeight($font) ;

$im = ImageCreateFromjpeg(“./PLACE_IMAGE_NAME_HERE.jpg”);
$x=imagesx($im)-$width ;
$y=imagesy($im)-$height;
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
imagestring ($im, $font, $x, $y,  $string, $text_color);

imagejpeg ($im);
?>

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/

Nice Content Editor


NicEdit is a Javascript/AJAX inline content editor to allow easy editing of web site content on the fly in the browser. It integrates into any site in seconds to make any element/div editable or convert standard textareas to rich text editing. You can try it right now by clicking on and editing this text using the controls at the top of the page!

NicEdit Form Submission
Post by Golam Robbany No extra configuration is normally needed to use NicEdit in place of textareas on forms. If users can type HTML in a current textarea it only takes one line of code to turn it into a rich text editor in your application!

Code:
<script type=“text/javascript”>
bkLib.onDomLoaded(function() {
new nicEditor({fullPanel : true}).panelInstance(‘comments’);
});
</script>

<strong>Enter your Name and Comments using the
NicEditor below</strong><br /><br />
<form method=“post” action=“examples3.php”>
Name : <input type=“text” name=“name” />
<textarea id=“comments” name=“comments” style=“width: 450px; height: 100px;”></textarea>
<input type=“submit” value=“Submit” />
</form>