我似乎无法找出为什么我的 PHP 不会与我的 HTML 链接。这个想法是根据调查弹出某些图片。例如,如果数字加起来超过 50,则会弹出“bromley.jpg”。尽管它只是说“宿舍”而不是图片,但这并没有发生。
<!DOCTYPE html>
<html>
<head>
<title> Find the right dorm for you </title>
<h1>Find out what dorm fits your lifestyle!</h1>
</head>
<body>
<p> Please fill out a few quesitons so we can help you figure out which dorm is best for you. </p>
<form method="get" action="slutsky1-results.php">
I enjoy (check all that apply):<br>
<input type="checkbox" name="act1" value="8">Working Out<br>
<input type="checkbox" name="act2" value="3">Bowling<br>
<input type="checkbox" name="act3" value="3">Live Music<br>
<input type="checkbox" name="act4" value="5">Shopping<br>
<input type="checkbox" name="act5" value="7">Food<br>
<input type="checkbox" name="act6" value="9">Bars <br>
<input type="checkbox" name="act7" value="9">Frat Parties <br>
<input type="checkbox" name="act8" value="8">Sports <br>
<input type="checkbox" name="act9" value="3">Library <br>
Is being close to the quad important to you?:
<select name= "Quad">
<option value="1">Not important</option>
<option value="3">Kind of important</option>
<option value="6">Very Important</option>
<option value="3">Only thing that matters</option>
</select>
<br>
How often do you plan on going to Red Lion?:
<select name= "Lion">
<option value="1">Never</option>
<option value="5">Sometimes</option>
<option value="10">Over 3 times a week</option>
</select>
<br>
Would you rather go to the ARC or CRCE?:
<select name= "Gym">
<option value="10">Arc</option>
<option value="1">CRCE</option>
</select>
<br>
How do you plan on eating most of your meals?:
<select name= "Gym">
<option value="5">Ordering delivery</option>
<option value="8">Walking To Green St.</option>
<option value="5">Making my own food</option>
</select>
<br>
Private or Public dorm?:
<select name= "Gym">
<option value="10">Private</option>
<option value="5">Public</option>
</select>
<br>
<input type="submit" value="get my results!">
</form>
</body>
</html>
slutsky1-results.php:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title> Dorm results! </title>
</head>
<body>
<h1> Your ideal dorm based on your answers is...</h1>
<p>
<?php
// Generates answer based on total numbers accumuated throughout survey.
$dorm= dorm ;
echo "Our reccomendation is $dorm <br>";
?>
<img src="<?php
if ($value > 50 ){
echo "bromley" ;
}
else if ($value>15 && $value <31) {
echo "Allen" ;
}
else if ($value>30 && $value <50) {
echo "peabody" ;
}
else if ($value>0 && $value <16) {
echo "PAR FAR" ;
}
?>.jpg">
</p>
</body>
</html>