PHP Program to replace the words with form and database
In this tutorial, we will learn about the followings.- PHP Program to replace the words
- PHP Program to replace the words with form
- PHP Program to replace the words with database
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<html> <head> <title>Replace the words</title> </head> <body> <?php for ($i=1; $i <=100 ; $i++) { if ($i%3==0 && $i%5==0) { echo $i."NO.1"."<br>"; }elseif ($i%3==0) { echo $i."WEBSITE"."<br>"."<br>"; }elseif ($i%5==0) { echo $i."T4TURORIALS.COM"."<br>"."<br>"; }else{ echo $i."<br>"; } } ?> </body> </html> |
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> <form method="post"> <input type="text" name="num"> <button name="sub">Clik_Me</button> </form> </body> </html> <?php if (isset($_POST['sub'])) { $num=$_POST['num']; for ($i=1; $i <= $num; $i++) { if ($i%3==0 && $i%5==0) { echo $i."NO.1"."<br>"; }elseif ($i%3==0) { echo $i."WEBSITE"."<br>"."<br>"; }elseif ($i%5==0) { echo $i."T4TUTORIALS.COM"."<br>"."<br>"; }else{ echo $i."<br>"; } } } ?> |
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> <body> <form method="post"> <input type="text" name="num"> <button name="sub">Clik_Me</button> </form> </body> </html> <?php $conn=mysqli_connect('localhost','root','','t4tuto'); if (isset($_POST['sub'])) { $num=$_POST['num']; $sql="INSERT INTO tutorials(num)VALUES('$num')"; $run=mysqli_query($conn,$sql); for ($i=1; $i <= $num; $i++) { if ($i%3==0 && $i%5==0) { echo $i."NO.1"."<br>"; }elseif ($i%3==0) { echo $i."WEBSITE"."<br>"."<br>"; }elseif ($i%5==0) { echo $i."T4TUTORIALS.COM"."<br>"."<br>"; }else{ echo $i."<br>"; } } } ?> |
Database to replace the words
