A simple program to show how to declare do while loop statement in PHP programming.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
<?php
$output = "";
if(isset($_POST["number"])){
$number = $_POST["number"];
$x = 1;
do {
$output .= "$x ";
$x++;
} while ($x <= $number);
}
if ($output != "") {
$output = '<p class="text-center mb-1">Your numbers are:</p><h3>'.$output.'</h3>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Do While Loop In PHP</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #fafafa;
min-height: 100vh;
padding: 50px 0;
}
form {
width: 400px;
}
</style>
</head>
<body class="d-flex justify-content-center align-items-center text-center">
<form action="" method="POST" class="card p-2">
<div class="card-body">
<h4>Simple Do While Loop In PHP</h4>
<h5>Jake R. Pomperada, MAED-IT, MIT</h5>
<hr>
<div class="my-4">
<label for="number" class="form-label">Enter a number:</label>
<input type="number" class="form-control" name="number" id="number">
<button type="submit" class="btn btn-primary btn-sm btn-block w-100 mt-2">OK</button>
</div>
<?php echo $output; ?>
</div>
</form>
</body>
</html>
No comments:
Post a Comment