【发布时间】:2015-12-28 19:18:36
【问题描述】:
当单击其他表的一行时,我想从同一页面中的一个表中获取一些数据。
这是我正在尝试做的事情的代码,但我被卡住了:
<?php
$db_table="area";
$db_query='select areaid,area_name from ' . $db_table;
$query_result=mysqli_query($dbc,$db_query) or die('error querying db');?>
<div id="area1" >
<h3>Select ony two area from Category </h3>
<form>
<fieldset style="float: left; width: 25%">
<legend>Project Area</legend>
<table border=1>
<tr>
<th> </th>
<th> Area Name </th>
</tr>
<?php
while($row=mysqli_fetch_array($query_result)){
?>
<tr id="<?php echo $row['areaid'];?>" class="area" onlick="showfaculty()">
<td> <input class="selectarea" type="radio" name = "proarea" value="<?php echo $row['areaid'];?>"></td>
<td> <?php echo $row['area_name']; ?></td>
</tr>
<?php }
echo '</table></br></br>
</fieldset>
<fieldset id="avaguide" style="width: 25%">
<legend>Available Guide</legend>
<table border=1>
<tr>
<th> </th>
<th> Available Guides </th>
</tr>';
$db_table2="facultytable";
$db_query='select facultyID,facultName from ' . $db_table2.' where project_count<2';
$query_result=mysqli_query($dbc,$db_query) or die('error querying db');
while($row=mysqli_fetch_array($query_result)){
?>
<tr id="<?php echo $row['facultyID'];?>" class="area">
<td> <input class="selectguide" type="radio" name = "areaguide" value="<?php echo $row['facultyID'];?>"></td>
<td> <?php echo $row['facultName']; ?></td>
</tr>
<?php }
echo '</table></fieldset>
</form>
</div>;`
现在我的代码运行良好,它同时显示了区域和教员表。但它显示完整的教师表。我想要做的是,当单击区域表的行时,应该调用某个函数,该函数从表 Faculty_area(a_id, f_id) 中获取所选区域 id 的所有教员 id,并且教员表仅显示获取的教员的名称教师编号下面是该函数的一个示例。
function showFaculty($aeraid){
$db_table2="faculty_area";
$db_query='select f_id from ' . $db_table2.' where a_id = '.$areaid;
$query_result=mysqli_query($dbc,$db_query) or die('error querying db');
while($row=mysqli_fetch_array($query_result)){ some code that can be used to display faculty table with feteched f_id}
请告诉我该怎么做。
【问题讨论】:
-
请努力帮助其他人了解您的问题。在此处粘贴表格结构并正确格式化您的文本。
-
你的代码到底是什么?或者,您是要求我们为您编码吗?
-
请不要期望下面会出现神奇的答案。这不是“堆栈如何滚动”。
-
欢迎来到 SO。请阅读What topics can I ask about 和How to ask a good question 和the perfect question SO 不是免费的编码服务