I'm back once again, I know you guys are probably tired of me lol but there are somethings I figured out how to add the text boxes. I am still having trouble with the drop down menu. I am supposed to have a drop down menu that has the list of the states and when you submit it, it will be abbreviated but that doesn't want to work for me either. I'm pretty sure it is something easy to fix and I keep over looking it.
<!DOCTYPE html>
<html>
<head>
<title>Lab 7, Part 1</title>
<meta charset="UTF-8"/>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
</head>
<body>
<form name="myform" action="http://weblab.kennesaw.edu/formtest.php"
onsubmit="return validateForm()"
method = "post">
<h1 style="text-align:center">Lab 7, Part 1</h1>
<h2 style="text-align:center">IT 3203</h2>
<a href="index.html"><p style="text-align:center">Main Page!</p></a>
<table>
<th>Fruits For Sale!</th>
<tr><th>Fruits</th><th>Weight</th><th>Price</th></tr>
<?php
$db=mysqli_connect(null,null,null,'weblab')
or die("Can't connect to DB:" . mysqli_connect_error());
$q = " select fruit_item_no, fruit_name, fruit_weight, fruit_price";
$q .= " from fruit_t";
$q .= " order by fruit_name;";
$dbResult = mysqli_query($db,$q);
$num = mysqli_num_rows($dbResult);
if ($num == 0) {
echo '<tr><td colspan="2">';
echo 'Database query retrieved zero rows.</td></tr>';
}
while ($row = mysqli_fetch_assoc($dbResult)) {
$name = $row['fruit_name'];
$weight = $row['fruit_weight'];
$price = $row['fruit_price'];
echo "<tr><td><b>$name</b></td>";
echo "<td>$weight</td>";
echo "<td>$price</td>";
echo "<td><input type='text' name='name'></td></tr>
";
}
?>
</table>
<br>
<label>First Name
<input type="text"
name="firstname" id="firstname"
size="25" />
</label>
<br>
<br>
<label>Last Name
<input type="text"
name="lastname" id="lastname"
size="25" />
</label>
<br>
<br>
<label>Street Address
<input type="text"
name="streetaddress" id="streetaddress"
size="35" />
</label>
<br>
<br>
<label>City
<input type="text"
name="city" id="city"
size="25" />
</label>
<label>State:
<select name="state" id="state">
<?php
$db=mysqli_connect(null,null,null,'weblab')
or die("Can't connect to DB:" . mysqli_connect_error());
$q = " select state_abbr, state_name";
$q .= " from state_t";
$q .= " order by state_name;";
while ($x = mysqli_fetch_assoc($dbResult)) {
$state_abbr = $x["state_abbr"];
$state_name = $x["state_name"];
?>
<option value="<?php echo $state_abbr; ?>">
<?php echo $state_name; ?></option>
<?php
}
?>
</select>
<?php
}
?>
</label>
<br>
<br>
<label>Zip code:
<input type="text"
name="zipcode" id="zipcode"
size="20" />
</label>
<br>
<br>
<label>Visa
<input type="radio" name="pref_payment"
id="pref_payment_visa" value="visa" checked />
</label><br>
<label>MasterCard
<input type="radio" name="pref_payment"
id="pref_payment_master" value="master" checked />
</label><br>
<label>American Express
<input type="radio" name="pref_payment"
id="pref_payment_american" value="american" checked />
</label><br>
<input type="submit" value="Submit!">
</form>
</body>
</html>