我正在学习php,我正在尝试添加一些修改项目状态的按钮。我设法让我的代码执行此操作并且它正在工作,但我确信它可以更好地编写,我想知道是否可以在不刷新页面的情况下完成此操作?任何想法将不胜感激。 感谢。
if (isset($_GET['status'])) {
$id = (int)$_GET['id'];
$status = (int)$_GET['status'];
$statusSql = "UPDATE projects SET status = '$status' WHERE id ='$id'";
$db->query($statusSql);
header('Location: projects.php');
}
........
<?php
if(($project['status']) == 0 ) {
echo "<a href='projects.php?status=1&id={$project['id']}' class='btn btn-xs btn-default'>
<span class='glyphicon glyphicon-play'></span>
</a>  New Project";
}elseif(($project['status']) == 1 ){
echo "<a href='projects.php?status=2&id={$project['id']}' class='btn btn-xs btn-default'>
<span class='glyphicon glyphicon-pause'></span>
</a>  In Progress  <a href='projects.php?status=3&id={$project['id']}' class='btn btn-xs btn-default'>
<span class='glyphicon glyphicon-stop'></span>
</a>";
}elseif(($project['status']) == 2 ){
echo "<a href='projects.php?status=1&id={$project['id']}' class='btn btn-xs btn-default'>
<span class='glyphicon glyphicon-play'></span>
</a>  On Hold</span>
</a>";
}elseif(($project['status']) == 3 ){
echo "<a href='projects.php?status=1&id={$project['id']}' class='btn btn-xs btn-default'>
<span class='glyphicon glyphicon-play'></span>
</a>  Finished</span>
</a>";
};
&GT;