Category: Php

Create daterange using function

function createDateRangeArray($strDateFrom,$strDateTo) { // takes two dates formatted as YYYY-MM-DD and creates an // inclusive array of the dates between the from and to dates. // could test validity of dates here but I’m...

Time Zone for PHP & Linux

Linux System Time ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur localtime Reference : http://www.thegeekstuff.com/2010/09/change-timezone-in-linux/     Php Time Method 1 : Add #date_default_timezone_set(‘Asia/Kuala_Lumpur’); At the starting of your script Method 2 : Find for /etc/php5/apache2/php.ini file Update to date.timezone = ‘Asia/Kuala_Lumpur’...

Ajax (Client’s Back – End)

function loadDoc() { var xhttp = new XMLHttpRequest(); //Open OOP xhttp.onreadystatechange = function() {// Do Something When result is return if (this.readyState == 4 && this.status == 200) { document.getElementById(“demo”).innerHTML = this.responseText; } };...

OUTPUT BUFFER ob (PHP)

  ob_start(); ob_flush(); header(“Location: YOUR LOCATION”); //Work   ob_start(‘ob_handler’); ob_flush(); header(“Location: YOUR LOCATION”); //Not Work

SQL VS PHP (Object oriented connection)

HOW TO ESTABLISH THE CONNECTION WITH DATABASE $db = new mysqli(<HOST NAME>,<DB USER>,<DB PASS>,<DB NAME>); HOW TO EXECUTE QUERY $query = “YOUR QUERY”; $result = $db->query($query); HOW TO LIST YOUR QUERY RESULT while($row =...