Posts

Showing posts from May, 2023

Es6 Module

Image
Export-Import in ES6 JavaScript's es6 allow you to organize the code components in the form of modules and can be import them into other modules. This makes code maintenance easier. If they are written in separate files. With the help of import and export keywords, Modules can be used in other programs. Using Export You can export a function or variable from any file. Let us create a file named employee.js, and fill it with the things we want to export. There are two types of exports: 1. Named and 2. Default. Named exports must be enclosed using curly braces. Default exports do not. Named Exports You can create named exports two ways. 1. In-line individually, or 2. All at once at the bottom. MOVETOP↑   Example In-line individually: export const empname = "benny" export const empage = 30 // first declare variable and export let empcompany = "xyz" export {empcompany } All at once at the bottom: employeerecord.js // first declare variable and export cons

PHP Mini Project for Beginners

Image
   PHP Mini Project for Beginners   Here is a small PHP Project, which will displays a list of items from the selected category.   This project gives you how to use a multidimensional array, function, and switch statement in Real-time scenario.    Description:   There is only one PHP file called main.php. Which implements above concepts in this project. 1. Nested array : array is a multidimensional array contains different category of products 2. Function : There is a function called display(). This function takes products array as  an argument and display all the products from the given array. 3. Switch statement : Identifies the category and calls display() function and passes the  products array(nested array key element which points to another array of products.  And some CSS Code     main.php      <html> <head> <title> PHP Mini Project </title> <style type= "text/css" > body { align: center ; margin : 50px ; } li { background-color : #f

Es6 Destructuring

Image
Es6 Destructuring  ES6HOME What is Destructuring Destructuring makes it easy to extract array values from any index. Using Destructuring With destructing, we can assign array items to variables:   const userdata = [ 'John' , 'john@gmail.com' , '123451234' ]; const [name,email, phone] = userdata ; // assiging array values to different variables.     When destructuring arrays, Keep in mind the order of the variables that you are providing. To extract only name,phone write the following way. const [name,,phone] = userdata ;       MOVETOP↑   Destructuring with Array Default values The following example shows how Array Destructuring Assignment will work with array Default value. const userdata = [ 'John' , 'john@gmail.com' , '123451234' ]; onst [name = "John" , email = "john@gmail.com" ] = [ "Doe" ]; console.log(name); // Deo console.log(email); // john@gmail.com     Using array destructurning

Es6 Array Functions

Image
 ES6 Array Methods     ES6HOME Es6 provided us many cool functions which helps us to code better. So in this blog we are going to discuss some of the best array functions. These functions can help you to develop efficient code with reduced complexity. So let's get started! concat() :  This method will combine two or more arrays and produce one single array object. const arr1 = [ 'a' , 'b' , 'c' ]; const arr2 = [ 'x' , 'y' , 'z' ];   const arr3 = arr1.concat(arr2); consol.log(arr3);   output:     ['a','b','c','x','y','z'];       map():     This method operated on each element in the array, and finally produce the new array with results.   const arr1 = [ '1' , '2' , '3' ]; const arr2 = arr1.map((x) => x * 2 );      output:      2,4,6         ES6HOME filter(): This filter function reads each element of the array and compares it with the given conditio

Insert Form DATE value into MySQL in PHP

Image
How to Insert Form DATE value into MySQL in PHP       This tutorial shows how to insert HTML date widget value into MySQL database in PHP,  when the user selects the date from the HTML form date widget/date picker, it will display the date in a dd-mm-yyyy format, whereas MySQL date format is yyyy-mm-dd . For this, PHP converts the date into MySQL supportable format and inserts into the database.  This is explained step by step in this tutorial. Where we will take the input type as date and insert date value in MySQL database using PHP when the form submitted by using method POST. For this, I have used a simple HTML Form for user interface.   Step 1: Create a table: tbl_users in your Database (MySQL) as follows:   -- -- Table structure for table `tbl_users` --   CREATE TABLE `tbl_users` ( `id` int ( 11 ) NOT NULL , `username` varchar ( 30 ) NOT NULL , `dob` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;   Step 2:   Create an index.php and copy the below code, c