我正在研究学生监督项目。我想创建一个包含可用项目主题的页面,当点击感兴趣的主题时,将该主题分配给具有该“id”的用户,并使链接不可用,例如,具有“可用”链接的主题可以更改'不可用'。
如果家里有人可以提供帮助,我真的会感到沮丧吗?由于
答案 0 :(得分:0)
你需要使用ajax,这样做并帮助你实时更改jquery
答案 1 :(得分:0)
我做了一些小改动,用jquery
执行此操作<body>
<table cellspacing="2" cellpadding="2" border="2">
<?php $sql = "Select * from prject_topic"; $result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td><?php echo $row['lecturer_name'];?></td>
<td><?php echo $row['topic'];?></td>
<td><span class="actu" id="<?php echo $row['project_id'];?>">
<?php echo $row['status'];?>
</span>
</td>
</tr> <?php } ?>
</table>
<script type="text/javascript">
$(function(){
//We capture the Click in the user item
$(".actu").on('click', function(){
//We take the ide of this item
var id = $(this).attr('id');
//We check the current status of the user
if($(this).html() == "Deactivate"){
var est = "Activate";
}else{
var est = "Deactivate";
}
//We made a request of type ajax sending by post the id for its update
$.post('#.php',
{
'id':id,
'est':est
},
//We received the response from our php file which may be a code as in the example...
function(data){
if(data=="200"){
//If yes, update the content of the selected item in real time
$("#"+id).html('Deactivate');
}else{
//In case of error, we send the information
alert("Unable to disable user");
}
})
})
})
</script>
</body>
代码是为了您的理解而编写的