Addition of the Feet and Inches program in PHP MySQL
Addition of the Feet and Inches program in PHP MySQL
In this tutorial, we will cover the following questions;
- Addition of the Feet and Inches programĀ
- Addition of the Feet and Inches program with a form
- Addition of the Feet and Inches program in PHP MySQL
Addition of the Feet and Inches programĀ
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 | <html> <body> <?php $feet=9; $inch=11; $feet1=4; $inch1=7; $sum=$inch +$inch1; $x=0; if($sum >11) { $x=intval($sum/12); $y=$sum%12; $sum1=$feet +$feet1 +$x; echo "Feet = $sum1 and Inches = $y"; } else { $sum1=$feet +$feet1; echo "Feet = $sum1 and Inches = $sum"; } ?> </body> </html> |
Addition of the Feet and Inches program with a form
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 28 29 30 31 32 33 34 35 36 | <html> <body> <h1>Assignment 4</h1> <h2> Addition of Feet and Inches</h2> <form method="post"> Enter Feet<br><input type="text" name="feet1"><br><br> Enter Inches<br><input type="text" name="inch1"><br><br> Enter Feet<br ><input type="text" name="feet2"><br><br> Enter inches<br><input type="text" name="inch2"><br><br> <input type="submit" name="submit"> <?php if(isset($_POST['submit'])){ $feet=$_POST['feet1']; $inch=$_POST['inch1']; $feet1=$_POST['feet2']; $inch1=$_POST['inch2']; $sum=$inch +$inch1; $x=0; if($sum >11) { $x=intval($sum/12); $y=$sum%12; $sum1=$feet +$feet1 +$x; echo "Feet = $sum1 and Inches = $y"; } else { $sum1=$feet +$feet1; echo "Feet = $sum1 and Inches = $sum"; }} ?> </body> </html> |
Addition of the Feet and Inches program in PHP MySQL
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <html> <head> <style> div { border: solid black; background-color:#00FF33; align:center; width:600px; height:400px; padding: 20px; } </style> </head> <body> <div> <h2> Addition of Feet and Inches</h2> <form method="post"> Enter Feet<input type="text" name="feet1"> Enter Inches<input type="text" name="inch1"><br><br> Enter Feet<input type="text" name="feet2"> Enter inches<input type="text" name="inch2"><br><br> <input type="submit" name="submit"> <?php $con=mysqli_connect("localhost","root","","add"); if(isset($_POST['submit'])){ $feet=$_POST['feet1']; $inch=$_POST['inch1']; $feet1=$_POST['feet2']; $inch1=$_POST['inch2']; $sum=$inch +$inch1; $x=0; if($sum >11) { $x=intval($sum/12); $sum=$sum%12; $sum1=$feet +$feet1 +$x; echo "Feet = $sum1 and Inches = $sum"; } else { $sum1=$feet +$feet1; echo "Feet = $sum1 and Inches = $sum"; } $sql= mysqli_query($con,"insert into adds(feet,inches) values('$sum1','$sum')"); } ?> </div> </body> </html> |