jQuery parentsUntil() Method with Example

AmitDiwan
Updated on 31-Dec-2019 07:40:08

266 Views

The parentsUntil() method in jQuery is used to return all ancestor elements between the selector and stop parameter value.SyntaxThe syntax is as follows −$(selector).parentsUntil(stop, filter)Above, the stop parameter is a selector expression, element or jQuery object. The filter parameter is a selector expression that narrows down the search for ancestors between the selector and the stops parameter.ExampleLet us now see an example to implement the jQuery parentsUntil() method − Live Demo div {    width:600px; } .demo * {    display: block;    border: 2px solid yellow;    color: blue;    padding: 10px;    margin: 10px; } ... Read More

imagechar Function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:38:45

150 Views

The imagechar() function draws a character horizontally.Syntaxbool imagechar( img, font, x, y, ch, color )Parametersimg: Creating an image with imagecreatetruecolor().font: Set font sizex: x-coordinatey: y-coordinatec: The character to draw.color: A color identifier created with imagecolorallocate().ReturnThe imagechar() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example wherein we are drawing a character with different coordinates and height/ width as shown in the above example:OutputThe following is the output:

Select and Insert Values with Preceding Zeros in a MySQL Table

AmitDiwan
Updated on 31-Dec-2019 07:37:56

148 Views

For this, you can use INSERT INTO SELECT statement along with LPAD(). Let us first create a table −mysql> create table DemoTable1967    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserId varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1967(UserId)    select LPAD(COALESCE(MAX(id), 0) + 1, 3, '0') from DemoTable1967; Query OK, 1 row affected (0.00 sec) Records: 1  Duplicates: 0  Warnings: 0 mysql> insert into DemoTable1967(UserId)    select LPAD(COALESCE(MAX(id), 0) + 1, 3, '0') from DemoTable1967; Query OK, 1 row affected (0.00 sec) ... Read More

Use IF-ELSE Condition in SELECT in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:36:35

1K+ Views

Let us first create a table −mysql> create table DemoTable1966    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(20),    PhotoLiked int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1966(UserName, PhotoLiked) values('Chris', 57); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1966(UserName, PhotoLiked) values('David', 100); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1966(UserName, PhotoLiked) values('Mike', 68); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1966(UserName, PhotoLiked) values('Sam', 78); Query OK, 1 row affected (0.00 sec)Display all ... Read More

jQuery prop() Method with Examples

AmitDiwan
Updated on 31-Dec-2019 07:35:43

620 Views

The prop() method in jQuery is used to set or return the properties and values of the selected elements.SyntaxThe syntax is as follows −$(selector).prop(property)ExampleLet us now see an example to implement the jQuery prop() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          var $val = $("div");          $val.prop("font-size", "1.6em");          $val.append("Property value = " + $val.prop("font-size"));       });    }); Adding Property Property OutputThis will produce the following output −Click the button to add a property −

Identify Column Existence in All Tables with MySQL

AmitDiwan
Updated on 31-Dec-2019 07:34:29

178 Views

To identify a column name, use INFORMATION_SCHEMA.COLUMNS in MySQL. Here’s the syntax −select table_name, column_name from INFORMATION_SCHEMA.COLUMNS where table_schema = SCHEMA() andcolumn_name='anyColumnName';Let us implement the above query in order to identify a column with its existence in all tables. Here, we are finding the existence of column EmployeeAge −mysql> select table_name, column_name    FROM INFORMATION_SCHEMA.COLUMNS    WHERE table_schema = SCHEMA()    AND column_name='EmployeeAge';This will produce the following output displaying the tables with specific column “EmployeeAge” −+---------------+-------------+ | TABLE_NAME    | COLUMN_NAME | +---------------+-------------+ | demotable1153 | EmployeeAge | | demotable1297 | EmployeeAge | | demotable1303 | EmployeeAge | | demotable1328 ... Read More

jQuery Position with Examples

AmitDiwan
Updated on 31-Dec-2019 07:32:45

185 Views

The position() method in jQuery is used to return the position of the first matched element. It returns the top and left positions in pixels.SyntaxThe syntax is as follows −$(selector).position()ExampleLet us now see an example to implement the jQuery position() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          alert("Top position: " + ($("h3").position()).top + " Left position: " + ($("h3").position()).left);       });    }); Heading One Heading Two Heading Three Position of h3 element OutputThis will produce the following output −Click the button to get left and top position of element −

Get Maximum Age from Records with Similar Student Names in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:31:31

1K+ Views

For this, you can use GROUP BY along with aggregate function MAX(). Let us first create a table −mysql> create table DemoTable1964    (    StudentName varchar(20),    StudentAge int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1964 values('Chris', 23); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1964 values('David', 34); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1964 values('Chris', 27); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1964 values('Sam', 31); Query OK, 1 row affected (0.00 sec) mysql> ... Read More

MySQL Query to Create User and Grant Permission

AmitDiwan
Updated on 31-Dec-2019 07:29:43

429 Views

To create a user and grant permission, the syntax is as follows −create database yourDatabaseName DEFAULT CHARACTER SET utf8; create user `yourUserName` identified by yourPassword; GRANT SELECT ON yourDatabaseName .* TO `yourUserName`; GRANT INSERT ON yourDatabaseName .* TO `yourUserName`; GRANT UPDATE ON yourDatabaseName .* TO `yourUserName`; GRANT DELETE ON yourDatabaseName .* TO  `yourUserName`; GRANT EXECUTE ON yourDatabaseName .* TO `yourUserName`;Here is the query to create user and grant permission −mysql> create database demo_app DEFAULT CHARACTER SET utf8; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> create user `John_123` identified by '123456'; Query OK, 0 rows affected (0.00 sec) ... Read More

jQuery replaceWith() Method with Examples

AmitDiwan
Updated on 31-Dec-2019 07:28:55

275 Views

The replaceWith() method in jQuery is used to replace selected elements with new content.SyntaxThe syntax is as follows −$(selector).replaceWith(content, function(index))Above, the content parameter is the content to insert, whereas function is to return the content to replace.ExampleLet us now see an example to implement the jQuery replaceWith() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          $("h2").replaceWith("This is it!");       });    }); div {    margin: 10px;    width: 60%;    border: 2px dashed orange;    padding: 5px;    text-align:justify; } Demo Heading Demo ... Read More

Advertisements