1 回答

TA贡献1893条经验 获得超10个赞
<html>
<body>
<?php
//student interface
$file = fopen("subject.csv","r");
$subjects = fgetcsv($file);
fclose($file);
//puts the csv file provided into a 2d array
$studentTable = array();
if (($handle = fopen("students.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$studentTable[] = $data;
} fclose($handle);
}
//creates list that will store list of girls emails
$usernames = array();
//runs through studentTable and appends emails to toEmail.
for ($I = 0; $I < sizeof($studentTable); $I++){
array_push($usernames, $studentTable[$I][0]);
}
?>
<h2> Select your subjects! </h2>
<form method="POST" action='handlestudents.php'>
<p> Select your name </p>
<select id='userN' name='userN'>
<option selected="selected">Choose one</option>
<?php
// Iterating through the product array
foreach($usernames as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
</select>
<p> Select your 1st choice subject </p>
<select id='choice1' name='choice1'>
<option selected="selected" >Choose a subject</option>
<?php
// Iterating through the product array
foreach($subjects as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
</select>
<p> Select your 2nd choice subject </p>
<select id='choice2' name='choice2'>
<option selected="selected" >Choose a subject</option>
<?php
// Iterating through the product array
foreach($subjects as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
</select>
<p> Select your 3rd choice subject </p>
<select id='choice3' name='choice3'>
<option selected="selected" >Choose a subject</option>
<?php
// Iterating through the product array
foreach($subjects as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
</select>
<p> Select your 4th choice subject </p>
<select id='choice4' name='choice4'>
<option selected="selected" >Choose a subject</option>
<?php
// Iterating through the product array
foreach($subjects as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
</select>
<p> Select your 5th choice subject </p>
<select id='choice5' name='choice5' >
<option selected="selected" >Choose a subject</option>
<?php
// Iterating through the product array
foreach($subjects as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
</select>
<p> Select your 6th choice subject (none is an option) </p>
<select id='choice6' name='choice6'>
<option selected="selected" >Choose a subject</option>
<?php
// Iterating through the product array
foreach($subjects as $item){
?>
<option value="<?php echo strtolower($item); ?>"><?php echo $item; ?></option>
<?php
}
?>
<option value = ""> None </option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>
- 1 回答
- 0 关注
- 99 浏览
添加回答
举报