index firstname lastname age [0] Mary Johnson 25 [1] Amanda Miller 18 [2] James Brown 31 [3] Patricia Williams 7 [4] Michael Davis 43 [5] Sarah Miller 24 [6] Patrick Miller 27 he above dataset in array, Write PHP code to sort thes nding order and print these data as the previous table

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

i need sol quickly !!!

index firstname lastname age
[0] Mary
Johnson 25
[1] Amanda
Miller
18
[2] James
Brown
31
[3] Patricia
Williams 7
[4] Michael
Davis
43
[5] Sarah
Miller
24
[6] Patrick
Miller
27
he above dataset in array, Write PHP code to sort thes
nding order and print these data as the previous table
Transcribed Image Text:index firstname lastname age [0] Mary Johnson 25 [1] Amanda Miller 18 [2] James Brown 31 [3] Patricia Williams 7 [4] Michael Davis 43 [5] Sarah Miller 24 [6] Patrick Miller 27 he above dataset in array, Write PHP code to sort thes nding order and print these data as the previous table
Expert Solution
Step 1

Steps involved to produce the desired output can be followed as :

a) Create a PHP array to consider the given dataset. It is important to notice that the given table has rows and columns so the array should be multi-dimensional.

b)Add the values into the array according to the given dataset.

c)Sort the array in ascending order.

d)Print the array.

e)Design the output in a tabular manner.

 

Step 2

To insert the values of the given dataset, a two-dimensional array, along with row and column values, is declared first. Here given table has 7 records so this two-dimensional array should consist of six one-dimensional arrays, each of them has values of horizontal cells of the given table.

For example, the two-dimensional array is named as $details where the values are inserted as below :

$details = array (
  array("[0]", "Mary", "Johnson", 25),
  array("[1]","Amanda","Miller", 18),
  array("[2]","James", "Brown", 31),
  array("[3]", "Patricia", "Williams", 7),
  array("[4]", "Michael" , "Davis" , 43),
  array("[5]", "Sarah", "Miller" , 24),
  array("[6]" , "Patrick" , "Miller" , 27),
);

 

Next, the sort() function in PHP arranges the array elements in a specific ascending order. The syntax to use the function is as below :

sort(array_variable)

So, for the above example, the elements of $details can be sorted by using the following coding snippet:

sort($details)

 

To print this array, print_r($details) can be used. But here the desired output should in a tabular form. So the table elements should be used for designing the output.

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mobile Devices
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education