Question

Hello, I was wondering if someone could help me with this PHP and HTML problem. Basically,...

Hello, I was wondering if someone could help me with this PHP and HTML problem. Basically, there is code for a multiplication table and i need to change it to support the following.

  1. Make the page background (not table background) to change among three colors of your choice.
  2. Use the drop-down list to specify the size of the multiplication table to be 8, 10, 12, and 14
  3. Put the multipliers in the first column and the multiplicand on the first row (make both italicized). The grid should show only the result.

This is a 3 part PHP and HTML problem. The code to start off with is below. This code needs to be edited to meet the 3 requirements above.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Multiplication Table</title>
<style>
    table, th, td {
        border: 1px solid black;
    }
    th, td {
        padding: 5px;
    }
    td {
        text-align: right;
    }
</style>
</head>

<body>
<?php
    // You need to have two indecies, $i and $j
    // The output should look like
    // 1x1=1 1x2=2 ...
    // 2x1=2 2x2=4 ...
    // ...    
  
    $size = rand(8,12);
  
    $bgcolor = array("DeepSkyBlue","LightSalmon");
    $color = $bgcolor[rand(0,1)];
    echo "$color";
    echo "<table bgcolor = $color>";
    for ($i=1; $i<= $size; $i++)
    {
        echo "<tr>";
        for ($j=1; $j<= $size; $j++)
        {
            echo "<td>";
            echo $i . "x" . $j . "=" . $i*$j;
            echo "</td>";
        }
      
        //echo "<br>";
        echo "</tr>";
    }
    echo "</table>";

?>

</body>

</html>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Step 1: Create a new PHP file named index.php and Paste the following code.

<=================(this line is not in the code)=================>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

<title>Multiplication Table</title>

<style>

table, th, td {

border: 1px solid black;

}

th, td {

padding: 5px;

}

td {

text-align: right;

}

</style>

</head>

<?php

$bgcolor = array("DeepSkyBlue","LightSalmon","LightYellow");

$color = $bgcolor[rand(0,2)];

echo "$color";

?>

<body bgcolor=<?php echo $color ?>>

<?php

if(isset($_GET["create"])){

// You need to have two indecies, $i and $j

// The output should look like

// 1x1=1 1x2=2 ...

// 2x1=2 2x2=4 ...

// ...

echo "<table>";

$size = $_GET["size"];

for ($i=0; $i<= $size; $i++)

{

echo "<tr>";

for ($j=0; $j<= $size; $j++)

{

if($j == 0){

echo "<td>";

if($i == 0){

}else{

echo "<i>".($i)."</i>";

}

echo "</td>";

}else if($i == 0) {

echo "<td>";

if($j != 0){

echo "<i>".($j)."</i>";

}

echo "</td>";

}else{

echo "<td>";

echo $i . "x" . $j . "=" . $i*$j;

echo "</td>";

}

}

//echo "<br>";

echo "</tr>";

}

echo "</table>";

}

else{

//// if you want to always show that drop down take this code out from this else block a

/// or just uncomment below code. and comment this code.

?>

<form action="index.php" method="GET">

<select id="size" name="size">

<option value="8">8</option>

<option value="10">10</option>

<option value="12">12</option>

<option value="14">14</option>

</select>

<input type="submit" name="create" value="Create" id="create">

</form>

<?php

}

?>

<!---

<form action="index.php" method="GET">

<select id="size" name="size">

<option value="8">8</option>

<option value="10">10</option>

<option value="12">12</option>

<option value="14">14</option>

</select>

<input type="submit" name="create" value="Create" id="create">

</form>

-->

</body>

</html>

<==================================>

Note: if you always want to show that dropdown just change uncomment the commented HTML code, and comment the code inside the else block.

Step 2: fire up your server and run this code.

Here is the sample output of the code.

E3 Multiplication Table x e Hello, I Was Wondering if Some X + ぐ → C O localhost/php/index.php DeepSkyBlue 8 Create

CMultiplication Table ← → c ⓘlocalhost/php/index.php?size-14&create-C.reate LightSalmon e Hello, I Was Wondering if Some × 12

3 Multiplication Table xC Hello, I Was Wondering If Someo x KC localhost/php/index.php?size-108tcreate-Create LightYellow 10

Any problem ask me in the comment section

Thumbs up is appreciated.

Add a comment
Know the answer?
Add Answer to:
Hello, I was wondering if someone could help me with this PHP and HTML problem. Basically,...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Predict the Result.Draw and write a brief description of the Web page that will becreated...

    1. Predict the Result.Draw and write a brief description of the Web page that will becreated with the following XHTML code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><title>CircleSoft Designs</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">body { background-color: #FFFFCC;color: #330000;font-family Arial,Helvetica,sans-serif; }.content { width: 750px; }</style></head>Apply Your Knowledge<body><div class="content"><h1>CircleSoft Design</h1><div><strong>CircleSoft Designs will </strong><ul><li>work with you to create a Web presence that fits yourcompany</li><li>listen to you and answer your questions</li><li>utilize the most appropriate technology for your sites:JavaScript, Java, PHP, databases,...

  • I am having an issue. When i press submit to test the code, it goes to...

    I am having an issue. When i press submit to test the code, it goes to a blank screen. Please, will some one assist me? Thanks! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Sign Guest Book</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php if (empty($_POST['?rst_name']) || empty($_POST['last_name']))     echo "<p>You must enter your ?rst and last name! Click your browser's Back button to return to the Guest Book form.</p>"; else {     $DBConnect = @mysql_connect("localhost", "root", "");    ...

  • Create an HTML form that takes these inputs: Number of rows, and number of columns. This...

    Create an HTML form that takes these inputs: Number of rows, and number of columns. This form will submit to a PHP page. Create that page that will accept input from the HTML form and generates the table from the user's input. I already have the portion that generates the table based on user input by using Javascript in an HTML page, I just need to know how to generate the table using a PHP page instead. Here's the code...

  • Im working with php but having problem displaying the correct result. I need to show Order...

    Im working with php but having problem displaying the correct result. I need to show Order processed at (time) HTML file: <!DOCTYPE html> <html> <head> <title>Bob's Auto Parts - Order Form</title> </head> <body> <form action="processorder.php" method="post"> <table style="border: 0px;"> <tr style="background: #cccccc;"> <td style="width: 150px; text-align: center;">Item</td> <td style="width: 15px; text-align: center;">Quantity</td> </tr> <tr> <td>Tires</td> <td><input type="text" name="tireqty" size="3" maxlength="3" /></td> </tr> <tr> <td>Oil</td> <td><input type="text" name="oilqty" size="3" maxlength="3" /></td> </tr> <tr> <td>Spark Plugs</td> <td><input type="text" name="sparkqty" size="3" maxlength="3" /></td>...

  • PHP Programming with MySQL - Why do I get the following error and how do I...

    PHP Programming with MySQL - Why do I get the following error and how do I connect to my database. Looks like I might need to use mysqli instead of mysql but I dont know how to do that or what to change. I appreciate it is you fixed anything that needs to be re-written. Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php:12 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 12 Line 12: $DBConnect =...

  • PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head>...

    PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head> <script> </script> </head> <body> <h2>Temperature Conversion Table</h2> <h4>Enter a starting value in degrees Fahrenheit and an increment value.</h4> <form name="myTemp" onsubmit="convertCelcius()" method="post"> <input type="text" name="temperature"> Enter an value in degrees Fahrenheit<br><br> <input type="radio" name="degIncrement" id="degIncrement5"> Convert in increment in 5 degrees<br> <input type="radio" name="degIncrement" id="degIncrement10"> Convert in increment in 10 degrees <br/><br/><input type="submit" value="Submit"> </form> <?php if( $_POST["temperature"] || $_POST["degincrement"] ) { //get he...

  • My 2nd Try asking the same "PHP Programming with MySQL question. When I run my code,...

    My 2nd Try asking the same "PHP Programming with MySQL question. When I run my code, I get the following messages: Notice: Undefined index: email in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Notice: Undefined index: password in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 75 The e-mail address/password combination entered is not valid. Please use your browser's BACK button to return to the form and fix the errors indicated. Please use...

  • <!DOCTYPE html> <html> <head> <title>Products</title> <style> .heading { text-align: center; font-size: 40px; } #menu { text-align:...

    <!DOCTYPE html> <html> <head> <title>Products</title> <style> .heading { text-align: center; font-size: 40px; } #menu { text-align: center; } #menu li { display: inline; font-size: 26px; margin-left: 20px; } .container{ overflow: hidden; margin: 30px; } img { float: left; width: 40vh; height: 40vh; margin-left: 10%; } table { float: right; margin-right: 10%; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { font-size: 26px; padding: 10px; text-align: left; } a { color: black; } a:visted {...

  • Develop a file loading app as shown below: User enters URL in an EditText. On the...

    Develop a file loading app as shown below: User enters URL in an EditText. On the on click listener of the load button, url’s data should be read into a html file in a separate thread as an asynchronous task.  Display a progress bar too. On the post execute method, display done text in a text view. On the click of Display button, data that’s stored in html file gets retrieved and displayed in text view. USING ANDRIOD STUDIO /...

  • Hello Ive been tryting to add the CDN of jquery to my html code and I...

    Hello Ive been tryting to add the CDN of jquery to my html code and I keep getting an error Need help with this : ​​ Navigate to www.code.jquery.com in your Chrome browser. On this page, you'll find different stable versions of jQuery. Select uncompressed for jQuery Core 3.3.1. Copy the <script> tag that is given to you. In store_hours.html, paste that tag directly above your body's closing tag. This is the jQuery CDN. After you paste this code into...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT