.addClass() and .removeClass() methods in jQuery

In jQuery, there are various methods like – switchClass(), toggleClass(), addClass() and removeClass() by using them you can easily add or removes classes in the elements.

For using switchClass() method you need to include jQuery UI library within your page but you can simply use toggleClass(), addClass() and removeClass() without any dependency other than jQuery.

In this tutorial, I discuss about addClass() and removeClass() method.

.addClass() and .removeClass() methods in jQuery

Read more

How to use Order by with Multiple columns in MySQL

The data is not displayed in any particular order when you simply fetch it from the MySQL table. For displaying data in some meaningful way ORDER BY clause is used.

This sorts your result on the basis of the column name specified in the clause within the SELECT query.

It allows us to –

  • Specify ordering in single or multiple columns
  • Define sort results in ASC or DESC format.

How to use Order by with Multiple columns in MySQL

Read more

Get checked Checkboxes value with PHP

Checkboxe­s are a versatile tool found on many we­bsites, allowing users to sele­ct their preferre­d choices among different options available­ with ease.

When you use it in your form and try to read all checked values as any other elements like –  text box, text area, radio button, etc.

echo $_POST['lang'];  // Checkbox element

you will get the last checked value.

You need to send the checkboxes value in the form of an Array when the form gets submitted then you can loop over $_POST values.

In this tutorial, I show how you can read submitted checked checkboxes values with PHP and also show how you can save it to the MySQL database.

Get checked Checkboxes value with PHP

Read more

How to Break the nested loop in PHP

The break statement in PHP is utilized to terminate the execution of the current loop or switch case statement. However, when dealing with nested loops and the intention is to exit from one or more of the outer loops, you can achieve this by providing a numeric value with the break statement.

This tutorial demonstrates the process of terminating a specified number of nested foreach, for, while, and do-while loops in PHP by utilizing the break statement.

How to Break the nested loop in PHP

Read more