0
我不確定我的代碼出了什麼問題。我收到消息「頁面無法正常工作」不知道爲什麼?我正在嘗試獲取「retrieve1.php」過濾器的詳細信息,但每次嘗試點擊學生過濾器時,我都會收到一條消息,指出「頁面無法正常工作」。我很感謝這裏的任何幫助。我的php搜索代碼有問題
<?php
echo "<body style='background-color:#DCDCDC'>";
include ("account.php");
($db = mysql_connect($hostname, $username, $password))
or die ("unable to connect to MYSQL database");
mysql_select_db($project);
$sql= "SELECT * FROM bpi_registration LEFT JOIN
bpi_schoolInfo on bpi_registration.id_school = bpi_schoolInfo.id_school";
\t
$query=mysql_query($sql) or die(mysql_error());
function grade()
{
\t $query= "select distinct class_name from bpi_classInfo";
\t $result=mysql_query($query) or die(mysql_error());
\t \t
\t \t
\t while ($value = mysql_fetch_array ($result))
\t {
\t echo "<option value='" . $value['class_name'] . "'>" . $value['class_name'] . "</option>";
\t }
}
function school()
{
\t $query= "select distinct school_name from bpi_schoolInfo";
\t $result=mysql_query($query)or die(mysql_error());
\t \t
\t \t
\t while ($value = mysql_fetch_array ($result))
\t {
\t \t echo "<option value='" . $value['school_name'] . "'>" . $value['school_name'] . "</option>";
\t }
}
function team()
{
\t $query= "select distinct team_name from bpi_teamProfile";
\t $result=mysql_query($query)or die(mysql_error());
\t \t
\t \t
\t while ($value = mysql_fetch_array ($result))
\t {
\t \t echo "<option value='" . $value['team_name'] . "'>" . $value['team_name'] . "</option>";
\t }
}
function students()
{
\t $query= "select * from bpi_registration";
\t $result=mysql_query($query)or die(mysql_error());
\t \t
\t \t
\t while ($value = mysql_fetch_array ($result))
\t {
\t \t echo "<option value='" . $value['first_name'].' '.$value['last_name']. "'>" . $value['first_name'].' '.$value['last_name']. "</option>";
\t \t
\t }
}
?>
<form action="retrieve1.php" method="GET">
<select name="Grade">
<option value="" selected="selected">Choose Grade</option>
<?php grade() ?>
</select>
<select name="School">
<option value="" selected="selected">Choose School</option>
<?php school() ?>
</select>
<select name="Team">
<option value="" selected="selected">Choose Team</option>
<?php team() ?>
</select>
<select name="Students">
<option value="" selected="selected">Choose Students</option>
<?php students() ?>
</select>
<input type="submit" value="Find" />
</form>
<table width="600" border="2">
<tr>
<th width="91"> <div align="center">First Name </div></th>
<th width="98"> <div align="center">Last Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">City </div></th>
<th width="97"> <div align="center">State </div></th>
<th width="59"> <div align="center">Country </div></th>
<th width="59"> <div align="center">View </div></th>
<tr>
<?php
if (isset($_GET['Students']))
{
while ($row=mysql_fetch_array($query))
{
echo $row['email'];
echo $row['address_city'];
echo $row['address_state'];
echo $row['address_country'];
}
}
?>
你有這個自己寫的或只是複製粘貼它的花括號結束了嗎? – Ikari
@Saitama爲什麼這個奇怪的問題?爲了回答你的問題 - 我正在觀看youtube上的視頻並遵循代碼的大部分內容。這裏沒有粘貼複製品。一切都是自學的 –
你的代碼佈局很糟糕,請嘗試使用一些標籤?您還沒有關閉您的
回答
您在選擇寫一個錯誤的代碼。使用下面的一個。
,你也缺少while循環
來源
2016-03-27 07:02:18 Ajay
它仍然不起作用 –
你能看到選擇框嗎? – Ajay
是的,這解決了它 –
你缺少}
來源
2016-03-27 07:03:23 Thiyagesan
是的,這解決了它。 –
相關問題