0

我下面的代码有问题..

我想显示与我的 $jid 的 ID 无关的数据,但我认为我的循环有问题。显示的第一个数据被删除并替换为最后一个结果......

继承人的代码。有人可以帮我解决这个问题吗

$check_exist_query = mysql_query("SELECT * FROM physical_abilities_assignment where job_title_id = $jid");

while($check_exist_row = mysql_fetch_array($check_exist_query)){
$list = "";
 $physical_title_id = $check_exist_row['2'];


if(empty($physical_title_id)){

    $display_abilities_query = "SELECT * FROM physical_abilities";
}else{

    $display_abilities_query = "SELECT * FROM physical_abilities WHERE id != $physical_title_id";
}

$display_abilities_result = mysql_query($display_abilities_query);

while($display_abilities_row = mysql_fetch_array($display_abilities_result)){

$abilities_name = $display_abilities_row[2];
  $abilities_id = $display_abilities_row[0];

$list .= "<tr>
                    <td $bgcolor align=center><input type=\"checkbox\" ".$check." name=\"job_title[]\" value=".$title_id." id=\"".$title_id."\"></td>
                    <td $bgcolor style=\"padding-left:5px;\">".$abilities_name."</td>
                    <td $bgcolor align=center><a onClick=\"return confirm('Are you sure you want to delete this entry?');\" href=?do=delete&id=". $row[0] ."><img src=\"images/delete-icon.png\" border=0 ></a>&nbsp;&nbsp;&nbsp;<a href=\"physical-abilities.php?id=$row[0]\"><img src=\"images/edit-icon.png\" title=\"Edit This\" border=0/></a></td>
       </tr>";

}

4

1 回答 1

1
$list = "";
$check_exist_query = mysql_query("SELECT * FROM physical_abilities_assignment where job_title_id = $jid");

while($check_exist_row = mysql_fetch_array($check_exist_query)){

 $physical_title_id = $check_exist_row['2'];


if(empty($physical_title_id)){

    $display_abilities_query = "SELECT * FROM physical_abilities";
}else{

    $display_abilities_query = "SELECT * FROM physical_abilities WHERE id != $physical_title_id";
}

$display_abilities_result = mysql_query($display_abilities_query);

while($display_abilities_row = mysql_fetch_array($display_abilities_result)){

$abilities_name = $display_abilities_row[2];
  $abilities_id = $display_abilities_row[0];

$list .= "<tr>
                    <td $bgcolor align=center><input type=\"checkbox\" ".$check." name=\"job_title[]\" value=".$title_id." id=\"".$title_id."\"></td>
                    <td $bgcolor style=\"padding-left:5px;\">".$abilities_name."</td>
                    <td $bgcolor align=center><a onClick=\"return confirm('Are you sure you want to delete this entry?');\" href=?do=delete&id=". $row[0] ."><img src=\"images/delete-icon.png\" border=0 ></a>&nbsp;&nbsp;&nbsp;<a href=\"physical-abilities.php?id=$row[0]\"><img src=\"images/edit-icon.png\" title=\"Edit This\" border=0/></a></td>
       </tr>";
}

echo $list;

尝试这个。

于 2012-06-29T16:36:37.240 回答