我目前正在从我的数据库中提取我需要的信息,但希望显示的信息根据下拉结果进行更改。我做了一些研究,并认为最好的方法是使用表格,但不确定它是如何工作的。
这是我下面的代码:
<section id="compare">
<select>
<option>Select Gym</option>
<option>fitness first</option>
<option>anytime fitness</option>
<option>the gym</option>
<option>its leisure ltd</option>
<option>the armoury</option>
</select>
<select>
<option>Select Gym</option>
<option>fitness first</option>
<option>anytime fitness</option>
<option>the gym</option>
<option>its leisure ltd</option>
<option>the armoury</option>
</select>
<section id="left">
<?php
mysql_select_db("gyms", $con);
$result = mysql_query("SELECT * FROM gym WHERE id='1'") or die ('Error: '.mysql_error ());
while($row = mysql_fetch_array($result)){
echo "<h1>" . $row['name'] . "</h1>";
echo "<p><h6>type</h6>" . $row['type'] . "</p>";
echo "<p><h6>price</h6>" . $row['price'] . "</p>";
echo "<p><h6>hours</h6>" . $row['hours'] . "</p>";
echo "<p><h6>parking</h6>" . $row['parking'] . "</p>";
echo "<p><h6>facilities</h6>" . $row['facilities'] . "</p>";
}
?>
</section>
<section id="right">
<?php
$result = mysql_query("SELECT * FROM gym WHERE id='2'") or die ('Error: '.mysql_error ());
while($row = mysql_fetch_array($result2)){
echo "<h1>" . $row['name'] . "</h1>";
echo "<p><h6>type</h6>" . $row['type'] . "</p>";
echo "<p><h6>price</h6>" . $row['price'] . "</p>";
echo "<p><h6>hours</h6>" . $row['hours'] . "</p>";
echo "<p><h6>parking</h6>" . $row['parking'] . "</p>";
echo "<p><h6>facilities</h6>" . $row['facilities'] . "</p>";
}
mysql_close($con);
?>
</section>
</section>