PHP - My SQL : abs() - numeric function Last Updated : 25 Mar, 2021 Comments Improve Suggest changes Like Article Like Report Problem Statement : In this article, we are going to perform database operation with abs() operation using php. So we are considering temperature database . Introduction : PHP stands for hyper text preprocessor, it also communicates with mysql database through xampp server. MySQL is an query language that is used to manage the databases. abs() abs() is used to return the positive value in a table. syntax : abs(data); Example : abs(-12)=12 abs(23) = 23 Consider the table: Convert the temperature column to positive. Query : SELECT city,ABS(temperature) FROM temperature; Result : city id : 1 -- temperature : 15 city id : 2 -- temperature : 455 city id : 3 -- temperature : 55 Steps Start xampp serverCreate a database named database and create table named temperature.Write php code to insert records into the table. temp.php PHP <?php //servername $servername = "localhost"; //username $username = "root"; //empty password $password = ""; //database is the database name $dbname = "database"; // Create connection by passing these connection parameters $conn = new mysqli($servername, $username, $password, $dbname); // Check this connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //insert records into table $sql = "INSERT INTO temperature VALUES (1,-15);"; $sql .= "INSERT INTO temperature VALUES (2,-455);"; $sql .= "INSERT INTO temperature VALUES (3,55);"; if ($conn->multi_query($sql) === TRUE) { echo "temperature successfully stored"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> Output: localhost/temp.php PHP code to perform abs() function by converting temperature negative to positive values form1.php PHP <html> <body> <?php //servername $servername = "localhost"; //username $username = "root"; //empty password $password = ""; //database is the database name $dbname = "database"; // Create connection by passing these connection parameters $conn = new mysqli($servername, $username, $password, $dbname); echo "<br>"; echo "abs() demo"; echo "<br>"; echo "<br>"; //sql query $sql = "SELECT city,ABS(temperature) FROM temperature"; $result = $conn->query($sql); //display data on web page while($row = mysqli_fetch_array($result)){ echo " city id : ". $row['city']," -- temperature : ". $row['ABS(temperature)']; echo "<br>"; } //close the connection $conn->close(); ?> </body> </html> Output : Comment More infoAdvertise with us Next Article PHP - My SQL : abs() - numeric function sravankumar_171fa07058 Follow Improve Article Tags : PHP Similar Reads PHP | is_numeric() Function The is_numeric() function is an inbuilt function in PHP which is used to check whether a variable passed in function as a parameter is a number or a numeric string or not. The function returns a boolean value. Syntax: bool is_numeric ( $var ) Parameters: The function accepts a single parameter which 2 min read PHP abs() Function The abs() function is an inbuilt function in PHP which is used to return the absolute (positive) value of a number. The abs() function in PHP is identical to what we call modulus in mathematics. The modulus or absolute value of a negative number is positive. Syntaxnumber abs( value )ParametersThe ab 1 min read PHP | gmp_neg() Function The gmp_neg() function is an in-built function in PHP which returns the negative of a GMP number (GNU Multiple Precision). Syntax : gmp_neg( $num ) Parameters : The function accepts only one mandatory parameter $num which can be either a GMP number resource in PHP 5.5 or a GMP object in PHP version 1 min read PHP-My SQL avg() aggregate function In this article, we are going to find the average of the column in the SQL database using PHP in Xampp server. We are taking an example of a food database to find the average cost of all the items of food. Let's discuss it one by one. Requirements - Xampp server Introduction :Here, we will see the o 4 min read PHP min( ) Function The min() function of PHP is used to find the lowest value in an array, or the lowest value of several specified values. The min() function can take an array or several numbers as an argument and return the numerically minimum value among the passed parameters. The return type is not fixed, it can b 2 min read PHP | is_real() Function The is_real() function is an inbuilt function in PHP which is used to check the given value is a real number or not. Syntax: bool is_real( mixed $var ) Parameters: This function accepts one parameter as mentioned above and described below: $var: It contains the value of variable that need to be chec 2 min read PHP | gmp_sub() Function The gmp_sub() is an in-built function in PHP which returns the subtraction of the two GMP numbers.(GNU Multiple Precision: For large numbers) Syntax: gmp_sub($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These param 2 min read PHP is_integer() Function The is_integer() function is an inbuilt function in PHP that is used to check whether the type of a variable is an integer or not. This function is an alias of is_int() function. Syntax: bool is_integer(mixed $value) Parameters: This function accepts a single parameter $value that holds the value wh 1 min read PHP | gmp_sign() Function The gmp_sign() is an in-built function in PHP which checks the sign of a given GMP number (GNU Multiple Precision: For large numbers). Syntax: gmp_sign($num) Parameters: This function accepts one GMP number $num as mandatory parameter shown in the above syntax. This parameter can be a GMP object in 2 min read PHP asin( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. One of such function is asin() function. The asin() function in PHP is used to find the arc sine of a number in radians. We already 2 min read Like