Q:-How do I calculate the Number of days between two days?
This could be done using strtotime() function in php with the dates given please create the following example.
<?php $date1=$_POST['date1']; $date2=$_POST['date2']; $First_date = strtotime($date1); $second_date = strtotime($date2); $datediff = $First_date - $second_date; echo floor($datediff/(60*60*24)); ?> <table bgcolor=#d38a2a> <form name="f1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <tr bgcolor=#ffffff><td>Date1:-</td><td><input type="text" name="date1"></td></tr> <tr bgcolor=#ffffff><td>Date2:-</td><td><input type="text" name="date2" ></td></tr> <tr bgcolor=#ffffff><td colspan=2 align="right"><input type="submit" value="Calculate"></td></tr> </form> | 10
|
Q;-How to export table data to Microsoft Excel with SELECT INTO OUTFILE statement?
Following example will be created a file called data.csv in C:\xampp\htdocs.Table used is in page (MySQL standard deviance and variance)
Following example will be created a file called data.csv in C:\xampp\htdocs.Table used is in page (MySQL standard deviance and variance)
<?php $username="root"; $password=""; $database="my_database"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query =mysql_query("SELECT * INTO OUTFILE '{$_SERVER['DOCUMENT_ROOT']}/data.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM vehicle"); $result = mysql_query($query); ?> |
|
No comments:
Post a Comment