What i'm trying to achieve here is whenever the user clicks on a radio button, it changes the task's status accordingly
<input type="radio" name="status"
<?php if($task->status == 'todo'){echo('checked');}?>
onchange = "change('todo')">Todo
<input type="radio" name="status"
<?php if($task->status == 'doing'){echo('checked');}?>
onchange = "change('doing')">Doing
<input type="radio" name="status"
<?php if($task->status == 'done'){echo('checked');}?>
onchange = "change('done')">Done
<script>
function change(status){
$.ajax({
url: "/changeStatus.php/",
type: "GET",
data: { 'status': status, 'task_id': '<?php echo($task->id); ?>' },
});
}
</script>
and in my "changeStatus.php" file
<?php
dd($_GET['status']);
$con=mysqli_connect("127.0.0.1","root","","project_management");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$status = $_GET['status'];
$task_id = $_GET['task_id'];
dd($status,$task_id);
$sql = "UPDATE 'tasks' SET 'status' = '$status' WHERE 'id' = 'task_id'";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
mysqli_close($con);
?>
the problem is that the Database is not updated when i click on the radio buttons, and there's no error too! any help is appreciated!
note: the reason why "laravel" is in the tag; is because the error when i changed it to using POST method (which should be the correct method) is returning an error in my app.js file (from laravel).
via Kevin fu