Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment you will build a table (HTML table tag) with sortable column

ID: 648928 • Letter: F

Question

For this assignment you will build a table (HTML table tag) with sortable columns. The data is below. You must create a way for the user to sort ascending or descending on each of the 4 columns. Number columns must sort numerically, not alphabetically.

The table must use the following data. The first row is the column header name.

State          Capital        2010 pop      pop rank

Alabama      Montgomery 4,779,736      23

Alaska         Juneau         710,231        47

Arizona      Phoenix        6,329,017      18

Arkansas      Little Rock    2,914,918      32

California     Sacramento 37,253,956 1

Colorado      Denver         5,029,196      22

Connecticut    Hartford      3,518,288      29

Delaware      Dover          897,934        45

Florida      Tallahassee    18,801,310 4

Georgia      Atlanta        9,687,653      9

Hawaii         Honolulu       1,360,301      42

Your table/page must allow sorting on any one of the 4 columns, and allow for both descending and ascending sort on the chosen column.

As you can see the first two columns are text values and the second two columns must sort numerically not alphabetically. Only display the data table once, showing the user selected sort (if there is any) or the default sort (state name, ascending) if no user sort is input.

You can implement this in any manner that works but I would suggest the following:

1. use a 2 dimensional associative array

2. translate the multidimensional array to an HTML table

Explanation / Answer

<html>
<body>
<input type=submit value="Ascending" name="ascvalue" id='ascvalue'></td>
<input type=submit value="Descending" name="descvalue" id='descvalue'></td>
<table>
<?php
$table=array(array("Alabama","Montgomery","4,779,736","23"),array

("Alaska","Juneau","710,23","47"));

foreach ($table as $rows => $row)
{
   echo "<table border='1' cellpadding="10" ><tr>";
   foreach ($row as $col => $cell)
   {
       echo "<td>" . $cell . "</td>";
   }  
echo "</tr></table>";
}
?>  
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote