Archive for the ‘ PHP ’ Category

Php 5 extend, array and __construct


// Declare a new class that extends xavier into regex
class zabyer extends xavier {
    // Declare a property to hold the filter criteria
    private $criteria;

    // Now make our constructor
    public function __construct(Iterator $i, $regex) {
        // Call the parents constructor, and store the regex
        parent::__construct($i);
        $this->criteria = $regex;
    }

    // Define accept
    public function accept() {
        // Just see if the regex matches the current item:
        return preg_match($this->criteria, parent::current());
    }
}

// Now to test this, first define an array of values
$arr = array('macanhan', 'tibongco', 'gusa', 'gaisan', 'sm', 'cogon', 'agusan');
// Now let's create a chained Iterator.  Make a xavier that wraps
// around an ArrayIterator, and only allows items with a 'y' in them.
$it = new zabyer(new ArrayIterator($arr), '/y/i');

// Now loop and echo these all out, should include tibongco, sm, agusan.
foreach ($it as $entry) { echo "{$entry}
\n"; }

JQPLOT With php, mssql and jquery.

jqplot line graph

jqplot line graph

You can download jqplot by this link : http://www.jqplot.com/

1st Step:

Sample Query using sql statement code. this code will set as data connector :

sql Query

sql Query

2nd step:

convert  php array to javascript array

foreach($mygraphMapet->magGrp as $array) {
$jsArray[] = array($array['Focus_Date'], (int) $array['Accomplishment']);
}
$dataArray = json_encode($jsArray);// return [[2010-02-10, 9826],[2010-02-11, 9680] ]
}
 Array(
    [0]=>Array
        (
            [WorkHrs]=>9826
            [Focus_Date]=>2010-02-10
        )

    [1]=>Array
        (
            [WorkHrs]=>9680            
            [Focus_Date]=>2010-02-11
        ))// javascript: [[2010-02-10, 9826],[2010-02-11, 9680] ]
PHP Code:

 

<?php
class graphEffbuncesPermandays {
private function minDate() // this function allowed to access inside the class only
{
global $mygraphMapet;// get

graphEffbuncesPermandaysQuery() form

$mygraphMapet->unaQuery($dataFrom, $dateTo, $location);// execute 1st the function unaQuery in order to exucute the $mygraphMapet->magGrp
foreach($mygraphMapet->magGrp as $array) {
$jsArray[] = array($array['Focus_Date'], (int) $array['Accomplishment']);
}
$dataArray = json_encode($jsArray);// return [[2010-02-10, 9826],[2010-02-11, 9680] ]
}
$rdata = '<div class="BackGroundContent">
<title>INLAV '.$mygraphMapet->plantation.' Bunches Accomplishments Graph </title>
<!--[if IE]><script language="javascript" type="text/javascript" src="testjs/excanvas.js"></script><![endif]-->
<link rel="stylesheet" type="text/css" href="css/jquery.jqplot.css" />
<link rel="stylesheet" type="text/css" href="css/examples.css" />
<!-- BEGIN: load jquery -->
<!-- END: load jquery -->
<!-- BEGIN: load jqplot -->
<script language="javascript" type="text/javascript" src="testjs/jquery.jqplot.js"></script>
<!-- to render rotated axis ticks, include both the canvasText and canvasAxisTick renderers -->
<script language="javascript" type="text/javascript" src="testjs/jqplot.canvasAxisLabelRenderer.js"></script>
<script language="javascript" type="text/javascript" src="testjs/jqplot.canvasTextRenderer.js"></script>
<script language="javascript" type="text/javascript" src="testjs/jqplot.canvasAxisTickRenderer.js"></script>
<script language="javascript" type="text/javascript" src="testjs/jqplot.dateAxisRenderer.js"></script>
<script language="javascript" type="text/javascript" src="testjs/jqplot.highlighter.js"></script>
<script language="javascript" type="text/javascript" src="testjs/jqplot.cursor.js"></script>
<style type="text/css" media="screen">.jqplot-axis-tick {}</style>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
line1='.$dataArray.';
dateNako = "'.$mindate.'";
gipiliNatype = "'.$myDateorWeek.'"
if(gipiliNatype == "day"){
plot1 = $.jqplot("chart", [line1], {
title:"INLAV '.$mygraphMapet->plantation.' Bunches Accomplishments Graph",
axes:{
xaxis:{
renderer:$.jqplot.DateAxisRenderer,
min: dateNako,
label:"DAYS",
tickInterval:"1 days",
rendererOptions:{
tickRenderer:$.jqplot.CanvasAxisTickRenderer},
tickOptions:{formatString:\'%b %#d, %Y\', fontSize:\'8pt\', fontFamily:\'Tahoma\', angle:-40, fontWeight:\'normal\', fontStretch:1}
},
yaxis:{
label:"BUNCHES",
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
},
highlighter:
{
bringSeriesToFront: true,
tooltipLocation: "e",
tooltipOffset: 0,
formatString: "<div class=\'jqplot-highlighter\'>%s: <strong>%s</strong></div>"
},
series:[{lineWidth:4, markerOptions:{style:"square"}, color:"#5FAB78"}]
});
}else{
plot1 = $.jqplot("chart", [line1], {
title:"INLAV '.$mygraphMapet->plantation.' Accomplishments Graph",
axes:{
xaxis:{
renderer:$.jqplot.DateAxisRenderer,
min: dateNako,
label:"WEEKS",
tickInterval:"1 week",
rendererOptions:{
tickRenderer:$.jqplot.CanvasAxisTickRenderer},
tickOptions:{formatString:\'%b %#d, %Y\', fontSize:\'8pt\', fontFamily:\'Tahoma\', angle:-40, fontWeight:\'normal\', fontStretch:1}
},
yaxis:{
label:"BUNCHES",
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
},
highlighter:
{
bringSeriesToFront: true,
tooltipLocation: "e",
tooltipOffset: 0,
formatString: "<div class=\'jqplot-highlighter\'>%s: <strong>%s</strong></div>"
},
series:[{lineWidth:4, markerOptions:{style:"square"}, color:"#5FAB78"}]
});
}
});
</script>
<div id="chart" style="margin-top:20px; margin-left:20px;"></div>
</div>
}
$mygraphMapet = new graphEffbuncesPermandaysQuery();// get the graphEffbuncesPermandaysQuery.php class

?>
hehe kapoy explain taas kaayo

INFORMATION