PHP program to find the cube root of a number with form and database
PHP program to find the cube root of a number with form and database
In this tutorial, we will learn about the followings.
- PHP program to find the cube root of a number with form and database.
- PHP program to find the cube root of a number with form and database.
- PHP program to find the cube root of a number with form and database.
PHP program to find the cube root of a number.
In this example, programmer stores the values in the variables. However, if you interested to see the program about taking values in the form, please see example 2.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Cube Root</title> </head> <body> <?php $num=64; $cube_root=pow($num,(1.0/3.0)); echo "Cube root of 64 is= $cube_root"; ?> </body> </html> |
PHP program to find the cube root of a number with form.
In this example, we will take the inputs from the user and store them in variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Cube Root</title> </head> <body> <form method="post"> Enter the number <input type="text" name="Number" /><br /> <input type="submit" name="submit" /> </form> <?php if(isset($_POST['submit'])) { $num=$_POST['Number']; $cube_root=(pow(
$num,(1.0/3.0))); echo "$cube_root"; } ?> </body> </html> |
PHP program to find the cube root of a number with a database.
In this example, we will take the inputs from the user and temporarily store them in variables and then finally stores them permanently in the database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form method="post"> <input type="text" name="name"/> <input type="submit" name="OK" /> </form> <?php $con=mysqli_connect("localhost","root","","CubeRootDB"); if(isset($_POST['OK'])){ $t =$_POST['name']; { $cr=(pow($t,(1/3))); //echo "<input value= $cr name = $cr/>"; } $sql=mysqli_query($con,"INSERT INTO pow (number,result) VALUES ('$t','$cr')"); echo "<input value= $cr />"; } ?> </body> </html> |
Database of PHP program to find the cube root of a number.