Testing and submitting your programs.
You are given the following file with HTML and PHP code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 9/24/06
-->
<?php
$color1 = "#FFA500"; // orange
$color2 = "#8B0000"; // dark red
?>
<html>
<head>
<title>
Alternating colors example
</title>
</head>
<body>
<ol>
<li>List element</li>
<li>Another list element</li>
<li>And another one</li>
<li>Finally, the last one</li>
</ol>
</body>
</html>
Your task is to write a PHP program that displays results of voting
for two candidates as color bars of two different colors. The
names of the candidates and the number of votes for each candidate are
set as variables in the beginning of the program (in order to use the
testing script, the number of votes
should be passed to the program as an input, via
$_GET['input1']
and $_GET['input2']
).
The code shows a sample of displaying a color bar followed by the name of a candidate as a table. The width of the color bar, the name of the candidate, and the votes are all fixed in the example. You need to change the program so that all of these settings depend on the variables (for instance, if the number of votes changes from 15 to 20 in $votes1, the width of the color bar is automatically set to 100px). You also need to add another table to display the votes for the other person.
Format the page any way you like. Add a header to explain what the
page is about.
Note the padding property for <td> in the embedded style
sheet. Feel free to change it if you prefer a different format.
Make sure to check your page for several different names and numbers of votes.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 2/9/06
-->
<?php
$name1 = "Bart Simpson";
$name2 = "Lisa Simpson";
$votes1 = 15;
$votes2 = 12;
?>
<html>
<head>
<title>
Voting results
</title>
<style type="text/css">
td {padding: 3px}
</style>
</head>
<body>
<table>
<tr>
<td style="background: blue; height: 20px; width: 75px;" />
<td>
Bart Simpson 15
</td>
</tr>
</table>
</body>
</html>
In the voting program in the previous question print out the name of the winner. If it's a tie, print out both names and a message saying that they got equal number of votes.
Recall the program hours.php that prints a greeting based on the time of the day (the lecture examples are posted here). Change the program so that, instead of printing the greeting, it prints out the time in the standard am/pm format. For instance, if the input is 13, the program should print 1pm. If the input is less than 0 or greater than 23, the program should print "Invalid time".
This page is a part of CSci 1101 course web site.