How to create a CSV file using PHP easily

In this video I have shown how to create a CSV file using PHP. The example is shown with the help of XAMPP server installed in windows 10 PC. The below code can be used to create a CSV file. <?php header(“Content-type: text/plain”); header(“Content-Disposition: attachment; filename=jinu.csv”); echo ‘”jinu”,”jawad”,”one”,”two”‘.”\n”; echo ‘”jinu”,”jawad”,”one”,”two”‘.”\n”;; echo ‘”jinu”,”jawad”,”one”,”two”‘.”\n”;; for ($x = …

Continue reading

Read a CSV file using PHP

In this video,I have shown how to read a CSV file using PHP. 1. Below code can be used to read the CSV file and show it exactly as a table in the PHP page. <?php echo ‘<table border=”1″>’; $start_row = 1; if (($csv_file = fopen(“F:\\readcsv\\country.csv”, “r”)) !== FALSE) { while (($read_data = fgetcsv($csv_file, 1000, …

Continue reading

Writing 10 Million rows to a text file using PHP

In this video I have shown how you can create a text file with 10 million rows in that using PHP. This example is shown in a XAMPP server. Below given code will create the file. <?php header(“Content-Type: text/plain”); header(‘Content-Disposition: attachement; filename=”jinujawad.txt”‘); for ($x = 0; $x <= 1000000; $x++) { echo “The number is: …

Continue reading

Create excel file in PHP without using any libraries

In this video I have shown you how you can create excel file in PHP without using any libraries. Just add 2 lines of code mentioned below in your php page. The page will create an excel file and download it. header(“Content-type: application/vnd.ms-excel”); header(“Content-Disposition: attachment; filename=chillyfacts.com.xls”); The example page I shown in the video is, …

Continue reading

Send SOAP Request and read XML response from PHP page

In this video I have shown how you can send a XML Soap request and read the XML response with in a PHP page. For testing this, I have found the website holidaywebservice.com which will give response for XML request we send. 1. The below image shows the request and response for a service from …

Continue reading

Run command prompt commands from PHP page

In this video I have shown how you can run command prompt commands from PHP page. shell_exec(‘ ‘) can be used for executing cmd commands from php page. The below image shows the ipconfig/all command executed from my pc. We can run the same command from PHP page. The code is as below. <?php $out=shell_exec(‘ipconfig/all’); …

Continue reading

Hide .php extensions, Custom url for PHP pages with parameters, htaccess

In this video I have shown how you can have custom URL for you PHP web site. It is done by htaccess file, Please note that htaccess file should be created in ROOT folder of your project. 1. Project files Web pages 2. index.php <a href=”index.php”>INDEX</a> | <a href=”ABOUT”>ABOUT</a> | <a href=”PRODUCT”>PRODUCT</a> | <a href=”CONTACT”>CONTACT</a> …

Continue reading

Connect MySQL database using PHP and Select values from Table

In this video I have shown how you can Connect to your MySQL database and select values from the table in that database. Here in this example I am connecting to local host MySQL database Connect to Database with below code <?php echo ‘Hello<br>’; $hostname=’localhost’; $username=’root’; $password=’root’; $database=’test’; $conn=new mysqli($hostname,$username,$password,$database); if(!$conn){ die(‘Error In connection’.mysqli_connect_error()); }else{ …

Continue reading