Category: DataBase

The phpMyAdmin allows us different ways to export the Table data. One of a method is CSV(Comma Separated Value).

There are two ways to create a CSV file with PHP –

  • By comma separated string, or
  • using fputcsv() method

I am using the fputcsv() method (writes an array to the file line by line) in the demonstration, where I am listing MySQL table data in the Tabular format and a button to export data.

When the export button gets clicked then creating a new CSV file and download it.

https://makitweb.com/how-to-export-mysql-table-data-as-csv-file-in-php/

DataBase PHP

DataBase

In PHPMyAdmin you can import data in the database table in various formats e.g. SQL, CSV XML, etc. formats.

While import CSV file in PHPMyAdmin need to make sure that it should be the valid format like – the number of columns, data.

Similar functionality can be implemented with PHP where read the uploaded file and insert the record in the MySQL database table.

It is possible to check for duplicate entry with PHP while import but it is not possible in PHPMyAdmin.

Import CSV file data to the MySQL using PHP

DataBase PHP

JSON stands for JavaScript Object Notation, it is a data interchange format which is also been used to passing data from the server.

It is the best and effective way when need to return multiple values as a response from the PHP script to the jQuery.

You couldn’t directly return an array from AJAX, it must have converted in the valid format.

In this case, you can either use XML or JSON format.

In the tutorial demonstration, I will return an array of users from AJAX, while return converts the array into JSON format using the json_encode() function in the PHP.

On the basis of response show data in tabular format.

Return JSON response from AJAX using jQuery and PHP

AJAX DataBase JQuery PHP

DataBase

Autocomplete search filter display suggestion based on the user input e.g. listing all products which start with character ‘a’.

It makes easier for the user to search for an item from the list and select it from the suggestion list.

Require jQuery AJAX for implementing this.

Whenever the user enters a character send an AJAX request to fetch records with PHP and display the result.

In the demonstration, I show a textbox to search users. When an item selected from the suggestion list then fetch details of the selected users and display on the screen.

Make Autocomplete search with jQuery AJAX

AJAX DataBase JQuery PHP

Using login page registered users sign in to the website and manage its account.

On the user successful login attempt need to define $_SESSION.

This helps to detect the user is actually logged in or not when going to another web pages and it also helps to display content according to the user.

In this tutorial, I show how you can create a Login page with PHP and MySQL.

Create simple login page with PHP and MySQL

DataBase PHP

If you are allowing the user to login with their username and password then you have to make sure that every user has the unique username.

When the user goes for registration on your site check username either after form submits or check it with AJAX while entering.

In this tutorial, I am using jQuery AJAX to check username is available or not.

Check username availability with jQuery and AJAX

AJAX DataBase JQuery PHP