AmitDiwan has Published 10744 Articles

MySQL query to select top n rows efficiently?

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:31:24

423 Views

Use index to select top n rows efficiently. Let us first create a table −mysql> create table DemoTable (StudentName varchar(100), StudentScore int ); Query OK, 0 rows affected (0.66 sec)ExampleInsert some records in the table using insert command −mysql> insert into DemoTable values('John', 34); Query OK, 1 row affected (0.19 ... Read More

What are multidimensional associative arrays in PHP? How to retrieve values from them?

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:30:47

2K+ Views

Multidimensional arrays store multiple arrays whereas associative arrays store key-value pairs as data. Grouped relation between data can be stored in multidimensional associative arrays.Example Live DemoOutputJoe 20An array is defined that contains various attributes of an employee. The employee array is accessed based on the index names and the data is ... Read More

How to check for multidimensional nature of an array in PHP

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:28:53

2K+ Views

The ‘rsort’ function can be used to check if an array is multidimensional or not. It takes one parameter, i.e the array that needs to be checked and returns yes or no depending on the nature of the array.Example Live DemoOutputIs the array multi-dimensional? bool(true)An array is defined that contains string ... Read More

Different ways of checking if an array is empty or not in PHP

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:27:29

550 Views

Using the ‘sizeof’ functionLet us see an example −Example Live DemoOutputThe array is empty!An array can be checked to see if it is empty or not in multiple ways. One method is to use the ‘sizeof’ function that sees if the array is empty. If yes, the size would be 0, ... Read More

Removing empty array elements in PHP

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 06:23:49

683 Views

To remove empty array elements in PHP, the code is as follows −Example Live DemoOutputAfter removing null values from the array, the array has the below elements -This 91 102 is a sampleAn array is defined, that contains strings, numbers and ‘null’ values. The ‘foreach’ loop is used to iterate over ... Read More

HTML DOM Input Time stepUp( ) Method

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 14:18:00

126 Views

The HTML DOM Input Time stepUp() method defines the number of minutes the Time field should increase.SyntaxFollowing is the syntax −Calling stepUp() method with a number, which by default is equal to 1inputTimeObject.stepUp(number)ExampleLet us see an example of Input Time stepUp method − Live Demo Input Time stepUp()   ... Read More

HTML DOM Quote Object

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 10:11:46

157 Views

The HTML DOM Quote Object represent the element of an HTML document.Let us create q object −SyntaxFollowing is the syntax −document.createElement(“Q”);PropertiesFollowing are the properties of quote object −PropertyExplanationciteIt returns and alter the value of the cite attribute of a quote element in an HTML document.ExampleLet us see an example ... Read More

HTML DOM Script Object

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 10:07:58

236 Views

The DOM Script Object represent the element of an HTML document.Create script objectSyntaxFollowing is the syntax −document.createElement(“SCRIPT”);Properties of script objectPropertyExplanationasyncIt returns and alter whether the script should be executed asynchronously or not.charsetIt returns and modify the value of the charset attribute of a script element in an HTML document.deferIt ... Read More

HTML DOM Option label Property

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 10:05:46

125 Views

The DOM option label property returns and alter the value of the label attribute of an option in an HTML document.SyntaxFollowing is the syntax −Returning labelobject.label2. Modifying labelobject.label = “text”ExampleLet us see an example of option label property − Live Demo    html{       height:100%;   ... Read More

HTML DOM Option value Property

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 10:04:22

159 Views

The HTML DOM option value property returns and modify the value of an option which is going to be sent over the server.SyntaxFollowing is the syntax −Returning valueobject.valueModifying labelobject.value = “text”ExampleLet us see an example of HTML DOM option value property − Live Demo    html{     ... Read More

Advertisements