Posts

Showing posts with the label Create CSV

Create CSV File In PHP Using Database Query

This is simple way to Create CSV File In PHP Using Database Query. If you want to create file dynamically. This code is helpfull for you. <?php $con =  new mysqli('127.0.0.1','root','pinturp1','usedb'); if ($con->connect_error) {     die("Connection failed: " . $con->connect_error); } $sql = "SELECT id,fname,lname,gender FROM test"; $result = $con->query($sql); $OutputBuffer = ""; $ExportDestinationPathWebServer = $_SERVER['DOCUMENT_ROOT'].'/pintu/uploads'; $inpFileName = "test.csv"; $OutputBuffer = "Unique ID,First Name,Last Name,Gender".CHR(13); /*If file already found delete it from directory*/ try {     if(file_exists($ExportDestinationPathWebServer.'/'.$inpFileName)) {         unlink($ExportDestinationPathWebServer.'/'.$inpFileName);     } } catch(Exception $e) {     echo $e->getMessage(); } $fh = fopen($ExportDestinationPathWebServer.'/'.$...

Create excel,Create CSV,pdf,xml file,Validate Email and Phone using Regex in coldfusion

Some tiny works in coldfusion for new programmers like create excel, pdf, and use of cfsavecontent,make first letter capital,Validate EmailID and Phone using regex etc. <cfoutput>     <!---Start : Make first letter capital of a name--->       <cfset UserName = "pintu">       #rereplace(UserName, '^(\w)(.*)', '\u\1\2')#     <!---End : Make first letter capital of a name--->         <!---Start: Create Excel File--->       <cfsetting enablecfoutputonly="Yes">       <cfcontent type="application/msexcel">       <cfheader name="Content-Disposition" value="filename=FileName.xls">       <!---Excel File Content--->       <table border="0">       <tr><td>Name</td><td>Marks</td...