Posts

Showing posts with the label function

export to excel in php

Image
Hi friends Excel files are great for many things. It might though be a little bit tricky to generate them on the fly with php. Therefor I will guide you exactly how to do it, quick and simple. Excel is a very useful format for lots of purposes. For example, exporting stats, member lists to hand over to economy department etc.   <?php echo "Export Data Using PHP"; echo ' <form action="'. $phpself.'"> '; echo '<input name="submit" type="submit" value="Export" /> </form> '; ?> } else { $dbc = mysql_connect("localhost","root",""); mysql_select_db("test",$dbc); $contents="ID,Title,Visit\n"; $user_query = mysql_query('select id,title,visit from wallpaper'); while($row = mysql_fetch_array($user_query)) { $contents.=$row[0].","; $contents.=$row[1].","; $contents.=$row[2]."\n"; } ...

get time difference in php

Image
Date and time is one function which is always like there in whatever website, project you create. The more simple they look like to start with the more complex they become. Complexity comes in when we put these functions into different loops conditions etc.  The line below show you how you can call function. The function expects to be given 2 strings representing the start and end values of a time or date. <?php echo 'Hi! My name is Ankit Kumar Chauhan. I am: '.getDifference(date("Y-m-d G:i:s"),'1985-10-02 00:00:00'). ' Years old.'; function getDifference($startDate,$endDate,$format = 6) {     list($date,$time) = explode(' ',$endDate);     $startdate = explode("-",$date);     $starttime = explode(":",$time);     list($date,$time) = explode(' ',$startDate);     $enddate = explode("-",$date);     $endtime = explode(":",$time);     $secondsDifference = mktime(...