Combine Strings from Many Rows in MySQL

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

353 Views

For this, you can use GROUP_CONCAT(). Use SUM() to add the User Id. Let us first create a table −mysql> create table DemoTable1960    (    StudentId int,    StudentName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1960 values(100, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1960 values(101, 'Bob'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1960 values(102, 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1960 values(103, 'Mike'); Query OK, 1 row affected (0.00 sec)Display ... Read More

imagecolorclosestalpha Function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:19:16

77 Views

The imagecolorclosestalpha() function gets the index of closet color with alpha value.Syntaximagecolorclosestalpha ( img, red, green, blue, alpha )Parametersimg: Image resource created with imagecreatetruecolor().red: Red color componentgreen: Green color componentblue: Blue color componentalpha: The transparency of image, with 0 indicating completely opaque, whereas 127 indicating completely transparent.ReturnThe imagecolorclosestalpha() function returns the index of the closest color in the palette.ExampleThe following is an example: Live Demo

ImageFlip Function in PHP

George John
Updated on 31-Dec-2019 07:18:28

321 Views

The imageflip() function is used to flip an image using given mode.Syntaxbool imageflip(img, mode )Parametersimg: An image resource created using imagecreatetruecolor()mode: The flip mode. Here are the possible values:IMG_FLIP_HORIZONTAL – Flips the image horizontally.IMG_FLIP_VERTICAL – Flips the image vertically.IMG_FLIP_BOTH – Flips the image both horizontally and vertically.ReturnThe imageflip() function returns TRUE on success or FALSE on failure.ExampleThe following is an example that flips an image horizontally:OutputThe following is the output:

Create Dynamic Table Name from Current Year in MySQL

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

1K+ Views

To create a table name like year (2019), use PREPARE statement. Let us first create a table −mysql> create table DemoTable1959    (    UserName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1959 values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1959 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1959 values('Bob'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1959;This will produce the following output −+----------+ | UserName ... Read More

imagepolygon Function in PHP

Arjun Thakur
Updated on 31-Dec-2019 07:17:56

392 Views

The imagepolygon() function is used to draw a polygon.Syntaxbool imagepolygon( $img, $points, $num_points, $color)Parameters$img: Create a blank image with imagecreatetruecolor() function.$points: An array with vertices of polygon.$num_points: Total number of vertices in a polygon.$color: A color identifier created with imagecolorallocate() function.ReturnThe imagepolygon() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:

jQuery Delay with Examples

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

434 Views

The delay() method in jQuery is used to set a delay to delay the execution of the next item in the queue.SyntaxThe syntax is as follows −$(selector).delay(speed, queue)Above, the parameter speed is the speed of delay, whereas the queue is the name of the queue.Let us now see an example to implement the jQuery delay() method −Example Live Demo    $(document).ready(function(){       $("button").click(function(){          $(".demo1").delay("slow").fadeIn();          $(".demo2").delay(500).fadeIn();       });    }); .demo1 {    margin:20px;    width:300px;    height:100px;    display:none;    background-color:red; } .demo2 { ... Read More

Display Auto Increment User ID Sequence Number to Begin from 001 in MySQL

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

735 Views

For this, use ZEROFILL and alter the table to begin from the same sequence −alter table yourTableName    change yourColumnName yourColumnName int(3) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY;To understand the above syntax, let us first create a table −mysql> create table DemoTable1958    (    UserId int,    UserName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Here is the query to alter generated sequence number to begin from 001:mysql> alter table DemoTable1958    change UserId UserId int(3) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY; Query OK, 0 rows affected (0.00 sec) Records: 0  Duplicates: 0  Warnings: 0Let ... Read More

Divide Column to Get Monthly Salary of Employees in MySQL Query

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

398 Views

Let us first create a table −mysql> create table DemoTable1957    (    EmployeeId int,    EmployeeName varchar(20),    EmployeeSalary int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1957 values(1, 'Chris', 240000); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1957 values(2, 'Bob', 120000); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1957 values(3, 'David', 180000); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1957 values(4, 'Mike', 650000); Query OK, 1 row affected (0.00 sec)Display all records from the table using ... Read More

Select Column If Condition is Met in MySQL

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

514 Views

Let us first get the current date −mysql> select curdate();This will produce the following output −+------------+ | curdate()  | +------------+ | 2019-12-15 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable1956    (    ProductId int,    ProductName varchar(20),    CustomerName varchar(20),    ShippingDate date    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1956 values(101, 'Product-1', 'Sam', '2019-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1956 values(102, 'Product-2', 'Carol', '2018-12-01'); Query OK, 1 row affected (0.00 sec) ... Read More

jQuery eq() Method

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

260 Views

The eq() method in jQuery is used to select an element with a specific index number. The index number begins at 0.SyntaxThe syntax is as follows −$(":eq(index)")Above, the parameter index is the index of the element.ExampleLet us now see an example to implement the jQuery eq() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          $("p:eq(2)").css("color", "orange");       });    }); Student Info This is a demo text. Exam Info This is a demo text. Teacher's Info This is a demo text. Click me OutputThis will produce ... Read More

Advertisements