Category Archive Uncategorized

ByShubham Jain

New Features Of Opencart 3.1.0.0 Alpha

Opencart released opencart 3.1.0.0 Alpha on 27 July 2019 with some major changes

We are mentioning a new feature of opencart 3.1.0.0 Alpha version.

In admin Side changes

1- Opencart 3.1.0.0 added the product option in the catalog menu.

2- Cron Job option added in Opencart that is used for scheduling task to be run at a certain time.

3-All the radio button design change.

 

4- Product Image Section design change and edit, clear and delete option added.

 

5-  Summernote  Editor replace with CKEditor in textarea.

 

6- Change the datepicker area.

7- jQuery library version updated v2.1.1 to v3.3.1.

8- Bootstrap library version updated v3.3.5 to v4.0.0

In-Store Side changes

1- Success And Error  design Change

2- shopping cart page link create while clicking on add to cart button.

 

3- In URL  language tag is already append

ByShubham Jain

How to read and write Excel file in CakePHP 3.X

How to read and write Excel file in CakePHP 3.X

PHPExcel library was the best library available in PHP to read and write Excel files. Now a new library PHPSpreadsheet is here with latest updates and support. PHP Spreadsheet is written in pure PHP and allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc.

PHPSpreadsheet is very simple to use in any PHP application. We are showing steps how to use PHP Spreadsheet in your CakePHP 3.X application.

  1. Install composer if not installed on your system. Follow this link to install composer
  2. Install PHPSpreadsheet in your project. Ex. for CakePHP 3.X , go to vendor folder and run composer require phpoffice/phpspreadsheet
  3. After installation import the library in your PHP file where you want to perform the action. See below to import in CakePHP 3.X
  4. Now you can use the various features of PHPSpreadsheet library. To use this library in CakePHP 3.X, examples are given below with source code.

 

Step 1:- Download the spreadsheet library.

The easy way to download library, first go to vendor folder and open. press shift+right click and click on(Open Powershell window here).go to the link and see the code which we marked .just copy and paste into the spreadsheet.And the link is

https://phpspreadsheet.readthedocs.io/en/develop/

go to the link and install PhpSpreadsheet.

Composer install php spreadsheet

Composer install php spreadsheet

Step 2:- Check library is installed on your project.

After running the above command, the PHPSpreadsheet library installed with name PHPOffice as shown in image below –

 

Step 3:- Create an XLSX file by below code in CakePHP-

controller :-EmployeesController.php

<?php 
namespace App\Controller; 
use Cake\ORM\TableRegistry;
use App\Model\Table\User; // <—My model
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Helper;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
require ROOT.DS. ‘vendor’ .DS. ‘phpoffice/phpspreadsheet/src/Bootstrap.php’ ;
class EmployeesController extends AppController {
public function exportExcelfile(){
$spreadsheet = new Spreadsheet();
$helper = new Helper\Sample();
$helper ->log( ‘Create new Spreadsheet object’ );
$spreadsheet  = new Spreadsheet();
//Set document properties 
$helper ->log(‘Set document properties’);
$spreadsheet ->getProperties()
->setCreator(‘shubh ‘)
->setLastModifiedBy(‘Arjun’)
->setTitle(‘Example’)
->setSubject(‘Example’)
->setDescription(‘Example’)
->setKeywords(‘office PhpSpreadsheet php’)
->setCategory(‘Example’);
// Add some data 
$helper ->log(‘Add some data’);
$spreadsheet ->setActiveSheetIndex(0)
->setCellValue(‘A1’, ‘Hello’)
->setCellValue(‘B2’, ‘world!’)
->setCellValue(‘C1’, ‘Hello’)
->setCellValue(‘D2’, ‘world!’);
$helper ->log(‘Rename worksheet’);
$spreadsheet ->getActiveSheet()
->setTitle(‘Simple’);
$writer = new Xlsx($spreadsheet);
$writer ->save(WWW_ROOT . ‘/files/ example.xlsx’);
die;
}
}

Step 4:- Read an XLS file by below code in CakePHP-

controller :-EmployeesController.php

<?php 
namespace App\Controller;
use PhpOffice\PhpSpreadsheet\IOFactory;
use Cake\ORM\TableRegistry;
use App\Model\Table\User; // <—My model
use Cake\Datasource\ConnectionManager;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Helper;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
require ROOT.DS.’vendor‘ .DS. ‘phpoffice/phpspreadsheet/src/Bootstrap.php’;

class EmployeesController extends AppController {

public function importExcelfile (){
$helper = new Helper\Sample();
debug($helper);
$inputFileName = WWW_ROOT . ‘example1.xls‘;
$spreadsheet = IOFactory::load($inputFileName);
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
var_dump($sheetData);
die(“here”);
}
}

 

Leave comments below if you face any difficulty in reading and writing Excel files in your PHP application.

 

ByShubham Jain

How to use AJAX using PHP and jQuery

Ajax

  • Ajax is an Asynchronous JavaScript and XML.
  • with the help of ajax is build the connection between the server and client.
  • This technology is used for quick and dynamic web pages.
  • Ajax is work without reloading the page.
  • Examples of applications using AJAX: Google Maps, Gmail, and Facebook tabs.

Step to ajax example:-

  • First, we download jquery jar file.
  • Create a client-side
  • Create a server-side page to process the request.

Ajax Example:-

To create ajax example, you need to use any server-side language e.g. Java, PHP etc. Here we are using PHP for generating the server-side code.

And client-side language is HTML, CSS and We are using ajax with jquery.

Example:-

  • First, we create an input

  <!DOCTYPE  html>

 <html lang=”en”>

<head> 
       <script> 
      function beforesubmit()
$.ajax({ 
     url: “table.php”,                                           // write url  here
type: “GET”,                                                  // url type is here like .(GET&POST)
data: “table= “+$(“#table”).val(),            // data type is here
success: function (response) {
 $(“#bb”). append(response);                    // output of ajax
                                                                          }
  });
 return false;                                                 // if error not submit the page
}
</script> 
 </head>
 <body>

<h1> Enter the number of which you want a table </h1>
 <form action=”” method=”Get”  id=”form”>
<input type=”text” placeholder=”number” id=”table” required=””>

<input type=”submit” value=”Submit” onclick=” return beforesubmit()”>
</form>
<div id=”bb”> </div>
<script src=”jquery.js”> </script>

</body></html>

 

  • on click=” beforesubmit()” executes the JavaScript function show Name every time a click is typed in the text box.
  • Create table.php page for server-side

 

 <?php $i = 1;
 $number = $_GET[‘table’];  // $number is a input value 
 for ($i ;$i<=10; $i++) {
 echo ($i*$number).” <br>”;  //print 10 times table value 
 }
 ?>

     Output

Final Page is 

ByShubham Jain

How do JOINs work in SQL? Three or more than three tables join In SQL

Join in SQL

A Join is used to combine row from two or more table .based on min one common column. there is various type of join.

      • Inner join
      • Left join
      • Right join
      • Full outer join
      • Self-join
  • Inner Join: – The most commonly used for the join is inner join .they also called Equijoin. Two tables combine with one condition (one row’s value match in both tables).

The syntax of an inner join:-

  [ Select tablename.columnname(s) from table1 Inner join table2 on table1.columnname =table2.columnname  ]

Ex: – we have two table first table names is a category and second is subcategory and the common row is category so let see how to use inner join in both tables.

(Category) 

 (subcategory)

                                                                                                                                                          

 

  [ select category.category id, category.category name ,subcategory.subcategory name FROM category INNER JOIN    subcategory ON category.category id =subcategory.category id  ]

 

(Output)

  • Left Join: – In the left join returns all record in the left table but only match record selected in the right table, unmatched record value null.

The syntax of a left join:-

  [ Select tablename.columnname(s) from table1 Left  join table2 on table1.columnname =table2.columnname  ]

 

Ex:- we have two table first table names is category and second is subcategory and the common row is category id so let see how to use Left join in both tables.

 

(category)

   (subcategory)

  [ select category.category id, category.category name ,subcategory.subcategory name FROM category Left JOIN    subcategory ON category.category id =subcategory.category id  ]

(Output)

 

 

 

 

 

  • Right, Join: – In the right join returns all record in right table but only match record selected in the left table, unmatched record value null.

The syntax of right join:-

  [ Select tablename.columnname(s) from table1 Right join table2 on table1.columnname =table2.columnname  ]

Ex: – we have two table first table names is a category and second is subcategory and the common row is category  so let see how to use Right join in both tables.

 

(category) 

  (subcategory)

                                                                                                            

  [ select category.category id, category.category name ,subcategory.subcategory name FROM category Right JOIN    subcategory ON category.category id =subcategory.category id  ]

(Output)

  • Full Outer Join: – this keyword returns all matching record in both tables .it put a null value on the place of the match not found. It can potentially return very large datasets.

The syntax of Full outer join:-

[  Select tablename.columnname(s) from table1 Full Outer join table2 on table1.columnname =table2.columnname  ]

 

  • Self Join: – Self Join is used for comparing itself.

The syntax of self-join:-

  [ Select tablename.columnname(s) from table1 Self join table2 on table1.columnname =table2.columnname  ]

Join in three tables

We have three table first table category second is subcategory and third is a product

The syntax of three table join:-

  [ Select tablename.columnname(s) from table1 Inner join table2 on table1.columnname =table2.columnname Inner join  table 3 on table2.columnname = table 3.column name  ]

 

Ex:-

(category)

(subcategory)

                                                                                                                 

(product)

   [select category.category id, category.category name,subcategory.subcategory id ,subcategory.subcategory name ,product.product name FROM category Inner JOIN    subcategory ON category.category id =subcategory.category id Inner join product on subcategory.subcategory id = product.subcategory id ]

 

(Output)

 

 

ByShubham Jain

How to export all of your website data to Excel/CSV using phpMyAdmin

Overview:-

Many times we might need to export our data from database to an Excel or CSV file. In e-commerce, we need many reports of our orders, products, categories in Excel or CSV file. Thanks to phpMyAdmin, you can simply get all of this data from phpMyAdmin. phpMyAdmin is a powerful tool to interact with MySQL or MariaDB database. We are listing how to import, export data from your MySQL or MariaDB database in simple steps. You can export your data in any format, major format are CSV, Excel, JSON, MS Word, PDF, Text, PHP Array, SQL, YAML etc.

Import Sql file in database

  1. Login into c panel.

Login into phpmyadmin

 

     2. Click on new button.

Add database in phpMyAdmin

  1. Enter the name of the database in the database box.

Enter database name in phpMyAdmin

(If you don’t know database name which u want to import, then right click on your file which u want to import, open into notepad)

SQL database file

You can see your database name in “use database name or Create Database ” as shown in the image above,

  1. Select the database you want to import.

Databases in phpMyAdmin
5. Click on “Import” tab at the top.

import data in phpMyAdmin

 

6. Click on choose file button, locate file in your computer which you want to import, open file.

7. Select file format in drop down list, and press go button

import sql file in phpMyAdmin

     8. Success. All the tables will show left side .

phpMyAdmin

How to export in database

  1. Click on database which you want to export, then click on export button

select database in phpMyAdmin

export database phpMyAdmin

      2. Select the desired format (You can choose MS Excel, SQL, and CSV etc.)

export database phpMyAdmin

      3. Press Go button.

 

How to export any custom query in database

1. Click on table.

2. Click on button as show in an image.

write custom query in phpMyAdmin

3. Write a query in a text field, press go button.

Run query in phpMyAdmin

4. Click in export button; Select the desired format (You can choose MS Excel, SQL, and CSV etc.).

Export data of query in phpMyAdmin

5. Click go button.

export data in phpMyAdmin

 

Done! You can now easily export all your products, categories, options, store details or can simply take backup of all of your database.