Category: PHP

On your Client-side with jQuery, JavaScript you cannot delete any files. You need to use Server-side scripting for doing it.

In PHP, you can simply use unlink() function this removed a file from your server if it exists.

Sometimes you have the requirement to delete a resource file without reloading the page. This cannot total done with PHP you need to use jQuery or JavaScript with it by which you need to send AJAX request to your server for removing a file and according to the response make changes on your Client-side.

What in the demonstration ?

For demonstration purpose, I create a number of <img> element with Delete Button. When the Button gets clicked then removing the file using jQuery AJAX and replace the <img> source with the default image.

How to delete file with jQuery AJAX

AJAX PHP

There are many cases when require to update certain part of the web page on the regular basis.

For example – showing live cricket or football score, display latest news feeds,etc.

There are two ways to send AJAX request on specified time –

  • By setInterval() and
  • By setTimeout() JavaScript functions.

Both do the same work but they are reliable for certain cases, which I discuss in this tutorial.

How to fire AJAX Request on Regular Interval

AJAX Jquery PHP

The phpMyAdmin allows us the number of ways to export the Table data one of the ways 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 downloading it.

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

DataBase PHP

With sorting the list it is easier for the user to locate items in a sorted list than unsorted. It rearranges the data in specific order (ascending or descending).

You can either use PHP or AJAX to get the sorted data.

I am using AJAX to sort the list in this tutorial.

In the demonstration, I am displaying the employee’s list and attach click event on the table column header. Whenever header gets clicked then send an AJAX request with column name to sort with.

Sorting the Table by clicking Header with AJAX

AJAX Jquery PHP

A tooltip is a small pop-up element which shows information when moving the mouse pointer to the element. You can dynamically update the tooltip content with AJAX if you don’t want to fix the content while creation.

You can add the tooltip to the element with Bootstrap, jQueryUI, or any other library.

I am using jQuery UI library in the tutorial.

In the demonstration, I am displaying the list of users and dynamically load information on the tooltip with AJAX on mouse hover.

Dynamically show data in the Tooltip using AJAX

AJAX Jquery PHP

By adding file upload to the project, there may case arrives where you have to check image width and height before upload if you only allowed image files for uploading.

This is very common in Job Application Forms where the user has only can upload its profile photo of given dimensions other it’s not uploaded.

In this tutorial, I explain you with an example how to implement it. For uploading, I am using AJAX and PHP and done restriction with JavaScript.

How to Validate Image width And Height Before Upload Using JavaScript

AJAX Javascript Jquery PHP

PHP provides ZipArchive Class which allows us to create Zip file. This class makes the file creation little easier.

Programmatically Zip creation mainly requires when preparing theĀ group of file and folders for downloading.

In the demonstration, I am creating a function that will read all files and folders from the specified directory and add them in the ZipArchive class object.

How To Create And Download A Zip File with PHP

PHP

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

If you want to add records sorting with header click on your existing pagination code then you need to write some extra code for it.

This improves the user experience while traversing on the long list of paginated records.

The user can easily sort a column and view the list e.g. sorting employee list by its salary, age, etc.

Table sort on header click in the pagination using PHP

PHP

It gives more flexibility to the user by allowing them to hide and show those columns which they don’t want to see on the list.

You can do this with jQuery by toggling the specific columns according to the selection.

In the demonstration, I am creating a table layout for listing the employee details and use check boxes to hide and show the table columns using jQuery.

How to Hide and Show the Table column using jQuery

Jquery PHP