A simple program that I wrote that will ask the user to give a number and then the program will generate an inverted triangle using the symbol of asterisk in php programming language.

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 at 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


    $res = "";
    if (isset($_POST["txtNum"])) {
        $num = $_POST["txtNum"];

        while ($num >= 0) {
            for ($i = 0; $i<=$num; $i++) {
                $res .= '*';
            $res .= "<br>";

        $res = "<p>".$res."</p>";

<!DOCTYPE html>
<html lang="en">
    <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>The Asterisk Problem</title>
        form {
            width: 250px;
            margin: 200px auto 0;
        fieldset {
            padding: 20px 25px 20px 20px;
        input {
            width: 100%;
    <form action="" method="post">
            <legend>The Asterisk Problem</legend>
            <label for="fname">Enter a number:</label>
            <input type="number" id="txtNum" name="txtNum"><br><br>
            <button type="submit">Submit</button>
        <?php echo $res; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *