In this activity you will improve the appearance of your forms.
form.php
<?php
include('database.php');
include('header.php');
include('menu.php');
// get list of heroes
$query = "SELECT * FROM heroes";
$args = array();
$hrslt = $pdo->prepare($query);
$hrslt->execute($args);
// get list of movies
$query = "SELECT * FROM appearances GROUP BY movie";
$args = array();
$mrslt = $pdo->prepare($query);
$mrslt->execute($args);
?>
<main>
<form name="add_hero" action="process_form.php">
<ul>
<li>
<label>Hero Alias:</label>
<input type="text" name="name" size="30" maxlength="50" hint="Iron Man">
</li>
<li>
<label>Identity:</label>
<input type="text" name="name" size="30" maxlength="50" hint="Tony Stark">
</li>
<li>
<label>Side:</label>
<ul>
<li><input type="radio" name="side" value="Hero" checked> Hero</li>
<li><input type="radio" name="side" value="Villain"> Villain</li>
</ul>
</li>
<li>
<label>First Appearance:</label>
<input type="number" name="year">
</li>
<li>
<label>Source of Power:</label>
<select name="power">
<option value="skill">Skill</option>
<option value="bio">Biological</option>
<option value="magic">Magic</option>
<option value="tech">Technology</option>
<option value="mutant">Mutant</option>
</select>
</li>
</ul>
<input type="submit" name="submit" value="Add Hero">
</form>
<form name="add_appearances" action="process_form.php">
<ul>
<li>
<label>Hero</label>
<select name="hero">
<?php
// display list of heroes
while($row = $hrslt->fetch()) {
?>
<option value="<?php echo $row['alias']; ?>"><?php echo $row['alias']; ?></option>
<?php
}
?>
</select>
</li>
<li>
<label>Movie</label>
<ul>
<?php
// display list of movies
while($row = $mrslt->fetch()) {
?>
<li><input type="checkbox" name="movie[]" value="<?php echo $row['movie']; ?>" id=""> <?php echo $row['movie']; ?></li>
<?php
}
?>
<li><input type="checkbox" name="movie[]" value="new" id=""> <input type="text" name="new_movie"></li>
</ul>
</li>
</ul>
<input type="submit" name="submit" value="Add Appearance">
</form>
</main>
<?php
include('footer.php');
?>
style.css
ol {
color: blue;
}
ol ol {
font-weight: 700;
}
ul {
list-style-type: none;
}
td, th {
border-width: 1px;
border-style: solid;
}
td {
padding: 10px;
}
table {
border-collapse: collapse;
}
header {
background-color:indianred;
border:darkred solid 2px;
height: 100px;
position: absolute;
left: 16%;
right: 0px;
top: 0px;
}
nav {
background-color: burlywood;
border:yellow solid 2px;
position: fixed;
top: 0px;
bottom: 0px;
width: 16%;
left: 0px;
}
main {
background-color: lightgree;
border: darkgreen solid 2px;
position: absolute;
top: 100px;
left: 16%;
right: 0px;
bottom: 80px;
overflow: scroll;
padding: 20px;
}
footer {
background-color: lightskyblue;
border: darkblue solid 2px;
position: absolute;
bottom: 0px;
height: 80px;
left: 16%;
right: 0px;
}
.content {
background-color:coral;
border:orangered solid 2px;
height: 400px;
padding: 40px;
margin: 20px;
display: inline-block;
width: 300px;
}
img {
float: left;
max-height: 250px;
border: solid 2px green;
margin: 20px 20px 20px 0px;
padding: 10px;
border-radius: 30px;
}
#album {
display: flex;
justify-content:space-between;
flex-wrap: wrap;
}
video {
max-height: 250px;
float: right;
clear: left;
margin: 20px 0px 20px 20px;
padding: 10px;
}
audio {
margin: 20px 20px 20px 0px;
padding: 10px 10px 10px 0px;
}
input[type=button] {
display: block;
}
figcaption {
display: block;
text-align: center;
font-family: 'Arial', sans-serif;
color: green;
}
<form name="add_hero" action="process_form.php">
<fieldset>
...
<input type="submit" name="submit" value="Add Hero">
</fieldset>
</form>
<form name="add_appearances" action="process_form.php">
<fieldset>
...
<input type="submit" name="submit" value="Add Appearance">
</fieldset>
</form>
<fieldset> divides your form into sets of fields, though in this case each fieldset is its own form.<fieldset> tag. <form name="add_hero" action="process_form.php">
<fieldset>
<legend>Add Hero</legend>
...
<input type="submit" name="submit" value="Add Hero">
</fieldset>
</form>
<form name="add_appearances" action="process_form.php">
<fieldset>
<legend>Add Appearances</legend>
...
<input type="submit" name="submit" value="Add Appearance">
</fieldset>
</form>
width: 10em;. Remember that em defines space in character widths. From a bit of experimentation, I know that 10em is sufficient for all our labels.width can't be applied to inline elements like <label>, so we need to change it to 'inline-block'.label {
display: inline-block;
width: 10em;
text-align: right;
}
input[type=text], input[type=number], select {
margin-left: 1em;
}
input[type=checkbox], input[type=radio] {
margin-left: 11em;
}
input[name=new_movie] {
margin-left: 0em;
}