8. Write a script that creates an associative or multidimensional array in PHP
a. And displays that array in a table
b. Create a form with at least two input fields and a Submit button.
c. Write a script that will validate that the user entered data in the input fields and that the fields are not blank when the Submit button is pressed
d. And returns the values entered in the input field when the Submit button is pressed.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
This demonstration is using WAMP (Windows,Apache,MySQL And PHP).
Question a :
Here a new web page with name "multi.php" is created, which contains following code.
multi.php :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- title for web page -->
<title>Multidimensional Array</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<?php
//creating multidimensional array
$trainers=array
(
array("John","Microsoft stack","10 years"),
array("Sam","Database","8 years"),
array("VK","Java","5 years"),
array("SR","Javascript framwork","6 years"),
array("KL","Web Technology","15 years"),
);
?>
<table border=1>
<tr>
<th>Trainer Name</th>
<th>Technology Stack</th>
<th>Working Experience</th>
</tr>
<!-- this loop goes till number of rows -->
<?php for($i=0;$i<5;$i++) {?>
<tr>
<!-- this loop will goes till number columns -->
<?php for($j=0;$j<3;$j++) { ?>
<!-- display each value from the array -->
<td><?php echo $trainers[$i][$j]?></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</body>
</html>
======================================================
Output : Open web page multi.php in the browser and will get the screen as shown below.
Screen 1 :multi.php

********************************
Question b ,c,d:
Here a new web page with name "PhpForm.php" is created, which contains following code.
PhpForm.php :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- title for web page -->
<title>PHP Form Validation</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<!-- <body> -->
<!-- form with action and method attribute -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<!-- textbox for name -->
Name :<input type="text" name="txtName"/>
<br/><br/>
<!-- textbox for age -->
Age :<input type="text" name="txtAge"/>
<br/><br/>
<!-- button to submit form -->
<input type="Submit" name="btnSubmit"/>
</form>
<?php
if(isset($_POST["btnSubmit"]))
{
$name=$_POST["txtName"];//name
$age=$_POST["txtAge"];//age
//checking name and age
if($name=="")
{ //display message
echo "Please provide name<br/>";
}
else if($age=="")
{ //display message
echo "Please provide age<br/>";
}
else if($age<18)
{ //display message
echo "Please provide age > 18.<br/>";
}
else
{
//display name and age
echo "Name : ".$name."<br/>";
echo "Age : ".$age."<br/>";
}
}
?>
</body>
</html>
======================================================
Output : open web page in the browser and will get the screen as shown below
Screen 1 :PhpForm.php

Screen 2 :Screen when name is empty

Screen 3 :Screen when age is empty

Screen 4 :Screen when age is <18

Screen 5 :Screen showing name and age

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
8. Write a script that creates an associative or multidimensional array in PHP a. And displays that array in a table b. Create a form with at least two input fields and a Submit button. c. Write a scr...
PHP Create an HTML Form that asks for a series of personal information from the user, and once the user presses the [SUBMIT] button, sends the data to a PHP script that generates HTML code displaying the data entered. The form should have the following fields: First Name (using the text input type) Last Name (using the text input type) E-mail Address (using the email input type) Phone Number (using the tel input type) Date of Birth (using the date...
Write a PHP script that obtains a URL and its description from user and stores the information into a database using MySQL. Create and run a SQL script with database named URL and a table named Urltable. The first field of the table should contain an actual URL, and the second, which is named Description, should contain a description of the URL. Use www.deitel.com as the first URL, and input Cool site! as its description. The second URL should be...
Create a C# Form with a textbox and a button. The box is for a user to enter a number of seconds. And when the user clicks the button, the program displays the equivalent number of hours, minutes and seconds using a MessageBox. Show method. If the seconds entered is less than 60, your program should only display the seconds; if the seconds is a least 60 and less than 3600, your program should display minutes and seconds; if the...
In Java.
Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
Develop an HTML form that could be used to enter your book information (Books, Authors, and Publishers) start with the HTML/JavaScript template provided Expand upon it! What field information would you enter into a system? Have your form use more then just character text fields ... radio buttons, pick lists, and other elements make your form easier to use and you don't need to do lots of JavaScript checks. What fields would be mandatory ... which could be left blank?...
Q1. rewrite the exercise on April 4 by adding the
following operations:
1) In the php script, create an associative array named
$order that stores the following values:
- the number of cheese toppings;
- the number of pepperoni toppings;
- the number of
ham
toppings;
- the size of the ordered pizza;
- the number of the ordered pizza;
- the total cost of the order;
- the discount rate;
- the total cost after the discount.
2) the...
PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...
Write a C++ program that uses a two dimensional array to display a table of probabilities for a pair of rolling dice. Your custom assigned range of values of each die are: 5 up to and including 10. Section 1 of Program - Specifications: The top row of the table, left to right, and the left column of the array, top to bottom, must contain the assigned range of values displayed on each of the die in ascending order populated...
Form Processing HTML
One of the most ubiquitous uses of JavaScript is validating form
data on the client side before it is submitted to the server. It is
done everywhere because it is fast and it gives you a great deal of
flexibility in how you handle errors insofar as the GUI is
concerned.
Attached is an image of some code I wrote (so Blackboard can't
mess it up). Some things to notice that will help you with the
lab....
Draw the UML DIAGRAM ALSO
PLEASE DRAW THE UML DIAGRAM.ALSO
in java
should use the program in java
For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class The Point3D class will have the...