• +91 946005504
  • ankitagrawal.an@gmail.com

Import large csv data into Mysql within seconds.

Here is the PHP script that will import your large CSV file data within seconds .

1. Copy the below code and paste into your file and save your file with “.php” extension or you can download file directly from here.
2. Copy your csv file and paste into the same folder where your php file exists.
3. Now run your php file in browser.
4. Browser will show a form with some fields . you have to fill your database and table details and in “Name of the file” field you have to fill your csv file name.
5. Click on submit button.

It will take some seconds and your all csv data will import into your mysql table.


$password= '';
$cons= mysqli_connect("$sqlname", "$username","$password","$db") or die(mysql_error());
$result1=mysqli_query($cons,"select count(*) count from $table");
//If the fields in CSV are not seperated by comma(,)  replace comma(,) in the below query with that  delimiting character 
//If each tuple in CSV are not seperated by new line.  replace \n in the below query  the delimiting character which seperates two tuples in csv
// for more information about the query http://dev.mysql.com/doc/refman/5.1/en/load-data.html
mysqli_query($cons, '
    LOAD DATA LOCAL INFILE "'.$file.'"
        INTO TABLE '.$table.'
        FIELDS TERMINATED by \',\'
        LINES TERMINATED BY \'\n\'
')or die(mysql_error());
$result2=mysqli_query($cons,"select count(*) count from $table");
echo "Success";
echo "<b> total $count records have been added to the table $table </b> ";
echo "Mysql Server address/Host name ,Username , Database name ,Table name , File name are the Mandatory Fields";

<title> csv2 sql</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

<form class="form-horizontal" action="" method="post">
    <div class="form-group">
        <label for="mysql" class="control-label col-xs-2">Mysql Host name</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="mysql" id="mysql" placeholder="">
    <div class="form-group">
        <label for="username" class="control-label col-xs-2">Username</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="username" id="username" placeholder="">
    <div class="form-group">
        <label for="password" class="control-label col-xs-2">Password</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="password" id="password" placeholder="">
    <div class="form-group">
        <label for="db" class="control-label col-xs-2">Database name</label>
        <div class="col-xs-3">
        <input type="text" class="form-control" name="db" id="db" placeholder="">
    <div class="form-group">
        <label for="table" class="control-label col-xs-2">table name</label>
        <div class="col-xs-3">
        <input type="name" class="form-control" name="table" id="table">
    <div class="form-group">
        <label for="csvfile" class="control-label col-xs-2">Name of the file</label>
        <div class="col-xs-3">
        <input type="name" class="form-control" name="csv" id="csv">
        eg. yourfile.csv  (Your file must be in same folder where this script exist)
    <div class="form-group">
    <label for="login" class="control-label col-xs-2"></label>
    <div class="col-xs-3">
    <button type="submit" class="btn btn-primary">Upload</button>

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Installing laravel on ubuntu step by step

Follow the following steps exactly to installing laravel on ubuntu operating system

Basic Need :

  1. apache server installed
  2. php 5.8 and above
  3. internet connection
  4. Root permission for terminal

// notice: in these steps i had use “brijesh” an an example for project name you can user your own porject name by replacing it with yours.

Step1: First install composer

user this link if needed more information // refference: https://getcomposer.org/download/

        use these command for installing composer

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

// to un install composer
php -r "unlink('composer-setup.php');"

Step 2: Change root directory path (if your server folder is “html” then goto html folder

cd /var/www/html

Step 3: Install Laraven with your project name ex.: brijesh

composer<em> create-project laravel/laravel your-project-name</em>

ex.: composer create-project laravel/laravel brijesh

step 4: Give permission to brijesh , App, Storage , Piublic

sudo chmod -R 755 /var/www/html/brijesh
sudo chmod -R 777 /var/www/html/brijesh/app
sudo chmod -R 777 /var/www/html/brijesh/storage
sudo chmod -R 777 /var/www/html/brijesh/public

Step 5: create virtual host

// copy and past default host file by below comand to your { PROJECT NAME }<em></em>
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/brijesh.conf

// edit your .conf file
sudo vim /etc/apache2/sites-available/brijesh.conf

// Add this code  { replace brijesh with your project name } save and exit

<VirtualHost *:>
 ServerAdmin admin@brijesh
 ServerName brijesh.com
 ServerAlias www.brijesh.com
 DocumentRoot /var/www/html/brijesh/public/index.php

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 <Directory /var/www/html/brijesh>
 AllowOverride All


// then press Esc and then write :wq and enter button end

Step 6: enable your vitural host

sudo a2ensite brijesh.conf
sudo service apache2 restart
 Step 7: change host url
// open host
sudo vim /etc/hosts

// there look like localhost 
 // add your host name like brijesh.com www.brijesh.com
 //save, exit and restart apache
sudo service apache2 restart


Type in url “www.brijesh.com” or “localhost/brijesh/public/index.php” 

if below screen appears brijesh.com

yo yo laravel starts woooo……….

notice : replace brijesh with you project name.


while installing laravel on ubuntu operating system if there is any problem please comment we will reply as soon as possible thanks.

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

WordPress Content Functions

These are the pre-define function defined in wordpress we just need to use 
it directly where we wanted.
the most common functions we normally use is get title , get site url etc.
So basically  these are for beginners  and you become expert while regular using this.
there are comment with every function to explain its functionality. 

// title of the post

<?php the_title(); ?>

// web site url 

<?php echo site_url(); ?>

// web site name 

<?php echo get_bloginfo(); ?>

// post body 

if ( have_posts() ) : the_post();

// get custom value of the post

$cusomVal = get_post_custom_values('name_of_custom_value', $post->ID);
echo $cusomVal[0] ;

// get post thumbnail 

<?php the_post_thumbnail(); ?>

// get thumbnail url

$post_thumbnail_id = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );

// post per page attributes (give the required number of post on the page)
  $args = array( 'posts_per_page' => 5, 'offset'=> 0 );
  $myposts = get_posts( $args );

// limited post text on the page (put this on the place the_content())and add ellipse in the end

<?php the_excerpt(); ?>

// get published date 
<?php echo get_the_date(); ?>

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Populate Select box dynamically by ajax in Cakephp

To populate a select box by cakephp ajax functionality.
Step 1.
In the end of your view (.ctp)file.This is your javascript code in cake.

$this->Js->request(array('controller'=>'ControllerName','action'=>'ajax_call'), array(
'async' => true,
'method' => 'post',
'data'=> $this->Js->serializeForm(array(
'isForm' => true,
'inline' => true))

Step 2.
In your controller file create function with that returns options string

public $helpers = array('Js'); //load Js helper
public function getBySubject(){
		$this->autoRender=false; //prevent to load default layout
//your code

step 3.
In the end or your layout file after your loaded scripts

if (class_exists('JsHelper') && method_exists($this->Js, 'writeBuffer')) echo $this->Js->writeBuffer();
// will write your cached scripts
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone

Create Custom Helper and call from view in cakephp 3.x

To create a custom helper in cakephp first create a file in Helper folder and Helper classes should be suffixed with ‘Helper’.

example- (YourProject/src/view/Helper/CustomHelper.php)

CustomHelper.php is our new helper with Helper suffix.

Now in CustomHelper.php you can create function like this example

namespace App\View\Helper;

use Cake\View\Helper;

class CustomHelper extends Helper {

	public function yourhelperfunction()
		//your function code here

How to call custom helper function in view file

To call custom helper function from view file use

  $getresponse = $this->Custom->yourhelperfunction();
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone