Question

PHP script that will take a set of two numbers and output them as a nested...

  • PHP script that will take a set of two numbers
  • and output them as a nested list
  • one number is for the main list items
  • the other is the sub list items
  • PHP functionality should be above the doctype
  • display the resulting HTML string via a variable in the echo statement within the body element of the webpage

script should be in PHP/HTML

Homework Answers

Answer #1

PHP File :PhpList.php

<?php

    if(isset($_POST['btnSubmit']))

    {

        //taking first number entered by user

        $firstNumber=$_POST['firstNumber'];

        //taking second number entered by user

        $secondNumber=$_POST['secondNumber'];

        //creating a nested list

        $list="<ul><li>".$firstNumber."</li><ul><li>".$secondNumber."</li></ul></ul>";

        echo $list;//display list on the web page

    }

?>

<!DOCTYPE html>

<html lang="en">

    <head>

        <!-- title for the web page -->

        <title>PHP Nested List</title>

        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1">

       

    </head>

    <body>

        <!-- form tag with method and action attributes -->

        <form method="post" action="PhpList.php">

    <!-- label for first number -->

    <label for="firstNumber">First Number</label>

    <!-- textbox for firstNumber -->

    <input type="text" name="firstNumber"/>

    <br><br>

     <!-- label for second number -->

     <label for="secondNumber">Second Number</label>

    <!-- textbox for secondNumber -->

    <input type="text" name="secondNumber"/>

    <br><br>

    <!-- button to submit form -->

    <input type="submit" name="btnSubmit"/>

</form>

    </body>

</html>
=============================================

Output :

Screen asking two numbers :

Screen showing nested list :

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
PHP calculator problem Create a calculator class that will add, subtract, multiply, and divide two numbers....
PHP calculator problem Create a calculator class that will add, subtract, multiply, and divide two numbers. It will have a method that will accept three arguments consisting of a string and two numbers example ("+", 4, 5) where the string is the operator and the numbers are what will be used in the calculation. It doesn't need an HTML form, all the arguments are put in through the method. The class must check for a correct operator (+,*,-,/), and a...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if input from user is empty -> get an error string variable if input is not empty -> use preg_match() to match the pattern $pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/"; -> if it's a matched, get a success string variable */           } ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link...
!DOCTYPE html html head style /style /head body h1This is a Heading/h1 pThis is a strongparagraph/strong,...
!DOCTYPE html html head style /style /head body h1This is a Heading/h1 pThis is a strongparagraph/strong, with some words more strongimportant/strong than others /p pThis is another paragraph./p ul liApple/li liOrange/li liPear/li /ul table tr thFirstname/th thLastname/th /tr tr tdPeter/td tdGriffin/td /tr tr tdLois/td tdGriffin/td /tr /table /body /html Your tasks for this Critical Thinking activity are: Hide the h1 element. It should not take up any space. Display the list items as inline elements. Display the strong elements as...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Hello! I'm getting this assignment wrong according to the cengage software. The code looks right to...
Hello! I'm getting this assignment wrong according to the cengage software. The code looks right to me but apparently it is not. May someone please take a look at it and let me know what I'm doing wrong. I just can't seem to find the error. I'm attaching the question below and below that I will attach my code. I appreciate any help you could provide. The book is: HTML5, CSS3, and JavaScript, 6th edition, Bundle Thanks QUESTION: General Flex...
In the previous assessment, you used a static set of named variables to store the data...
In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...