function getStudent(){Glad can share ☺
$CI=& get_instance();
$q = $CI->db->query("select * from student");
return $q->result();
}
Sabtu, 21 Januari 2017
Query Database In Library Codeigniter
We usualy query in model, but sometime we need query in library codeigniter. This is sample code to do that.
Jumat, 20 Januari 2017
Check All Checkbox Jquery
To check or uncheck all checkbox we can using this simple script
$('#cek_all').click(function (event) { //on clickGlad can share☺
if (this.checked) { // check select status
$('.checkboxs').each(function () { //loop through each checkbox
this.checked = true; //select all checkboxes with class "checkboxs"
});
} else {
$('.checkboxs').each(function () { //loop through each checkbox
this.checked = false; //deselect all checkboxes with class "checkboxs"
});
}
});
Rabu, 11 Januari 2017
PHP Generate Code XXYYMMXXXX Function
This PHP function to generate patter code xxYYMMxxxx ex.GG17010002
function get_new_code_opb()
{
$code=''; // you can fill this using prev code with same pattern
$kode=substr($code, -4);
$num=(int)$kode;
$month=substr($code, -6,2);
if($num==0 || $num==null || $month!=$month_now)
{
$temp = 1;
}
else
{
$temp=$num+1;
}
if($dt==''){
$today = date('ym');
}
$id="XX".$today."".str_pad($temp, 4, 0, STR_PAD_LEFT); //XX can change into your prefix
return $id;
}
This code return by 1 if month changed
function get_new_code_opb()
{
$code=''; // you can fill this using prev code with same pattern
$kode=substr($code, -4);
$num=(int)$kode;
$month=substr($code, -6,2);
if($num==0 || $num==null || $month!=$month_now)
{
$temp = 1;
}
else
{
$temp=$num+1;
}
if($dt==''){
$today = date('ym');
}
$id="XX".$today."".str_pad($temp, 4, 0, STR_PAD_LEFT); //XX can change into your prefix
return $id;
}
This code return by 1 if month changed
Selasa, 10 Januari 2017
Javascript Popup Function
This is example code for pupup new window using javascript
function show_popup() //
{
var width = 800;
var height = 500;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height+',scrollbars=yes';
params += ', top='+top+', left='+left;
window.open('popup.php','',params);
}
function show_popup() //
{
var width = 800;
var height = 500;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height+',scrollbars=yes';
params += ', top='+top+', left='+left;
window.open('popup.php','',params);
}
Langganan:
Komentar (Atom)