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 に答える