Can someone help me finish this with php dropdown list and show table

Create a web page that produces the following HTML select options:

Use a configuration file called myConfig.php and a class called htmlHelper

$SELECTS[‘GW’] = ‘Geometry Wars’;

$SELECTS[‘HW’] = ‘Heros Of WarCraft’;

$SELECTS[‘MC’] = ‘MineCraft’;

$SELECTS[‘Room’] = ‘The Room Three’;

$SELECTS[‘SC’] = ‘SoulCalibur’;

$SELECTS[‘RS’] = ‘Rockstar’;

$SELECTS[‘RT’] = ‘RipTide GP’;

$COSTS[‘GW’] = 9.99;

$COSTS[‘HW’] = 3.99;

$COSTS[‘MC’] = 6.99;

$COSTS[‘Room’] = 4.99;

$COSTS[‘SC’] = 13.99;

$COSTS[‘RS’] = 4.99;

$COSTS[‘RT’] = 2.99;

$TYPES[‘GW’] = ‘Fighting’;

$TYPES[‘HW’] = ‘Fantasy’;

$TYPES[‘MC’] = ‘Adventure’;

$TYPES[‘Room’] = ‘Adventure’;

$TYPES[‘SC’] = ‘Fighting’;

$TYPES[‘RS’] = ‘Fantasy’;

$TYPES[‘RT’] = ‘Adventure’;

Here is the mainline code to use … you need to implement the htmlHelper class and get it to work with this code:
print “< html > < head >< /head >< body >”;
print “\n < form action=‘processSelects.php’ method=’get’>”;
$h = new htmlHelper( $SELECTS ); //Create class with the select options

$h->setSize( 4 ); //Sets the select window size
$h->setMultiple( true ); // if true allow multiple items to be selected
$h->showSelect(‘Game’); //Displays the select drop down
print "\n< br /> ";
print "\n< br /> “;
print “\n< /form>”;
print < /body>< /html>”;

  1. Write a program called processSelects.php that receives the items selected from Q1. Produce the following table of total costs of games selected and costs selected by type. Hint: you will use the $COSTS and $TYPES arrays to process the select options sent to you.
    So for example, if you selected all the items in the drop down from Q1, you would output the following (see below):
  2. The first table (Total Costs) shows the game selected, game cost, and cumulated costs of the games selected. Note the last rows shows total games selected and total costs of all selected games in bold.
  3. The second table (Total Costs By Type) summarizes the total costs by Game Type (e.g., Fighting, Fantasy, etc). Note you will need to use the $TYPES array from the config file.

You could place the php code between code tags… this is unreadable.

1 Like

already did it, could you help me about it?
I got some idea form my classmate, he didn’t use the function to make the table
he just print them out, like
“print (”< select name=‘Game[]’ size=‘4’ multiple>");
// echo ’ < option>’ .$SELECTS[‘GW’] = ‘Geometry Wars’. ‘< /option>’;
// echo ’ < option>’ .$SELECTS[‘HW’] = ‘Heros Of WarCraft’. ‘< /option>’;
// echo ‘< option>’ .$SELECTS[‘MC’] = ‘MineCraft’. ‘< /option>’;
// echo ‘< option>’ .$SELECTS[‘Room’] = ‘The Room Three’. ‘< /option>’;
// echo ‘< option>’ .$SELECTS[‘SC’] = ‘SoulCalibur’. ‘< /option>’;
// echo ‘< option>’ .$SELECTS[‘RS’] = ‘Rockstar’. ‘< /option>’;
// echo ‘< option>’ .$SELECTS[‘RT’] = ‘RipTide GP’. ‘< /option>’;
// print("< /select>");
// return ‘Game’;"

but it’s not flow the requirement

Sponsor our Newsletter | Privacy Policy | Terms of Service