Category: Php

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 already doing // that in the main script $aryRange=array(); $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2), substr($strDateFrom,8,2),substr($strDateFrom,0,4)); $iDateTo=mktime(1,0,0,substr($strDateTo,5,2), substr($strDateTo,8,2),substr($strDateTo,0,4)); if ($iDateTo>=$iDateFrom) { array_push($aryRange,date(‘Y-m-d’,$iDateFrom)); // first entry while […]

Linux Php

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’ LINE 883 /etc/init.d/php5-fpm restart  

javascript Php

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; } }; xhttp.open(“GET”, “ajax_info.txt”, true); xhttp.send(); }   //Ajax doing at back end as client , it can changes the front end display […]

MySQL Php

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 = $result->fetch_array(MYSQLI_ASSOC)){ echo “Hi ” .$row[‘Name’]. “, Your Email is” .$row[‘Email’]. ” and your phone number is ” .$row[‘Phone’] ; }

Back To Top