I am trying change one column value with a link, like if the column value is published it will changed to unpublished and vice versa. But the problem is that only if condition is working not else if.
Here is the link:
echo "<td><a href='testi.php?change_status={$testi_id}&status={$testi_status}'>Publish / Unpublish</a></td>";
And the php code to change the status:
<?php
if(isset($_GET['change_status'])){
$the_status = escape($_GET['status']);
$the_testi_id = escape($_GET['change_status']);
if ($the_status='published'){
$query = "UPDATE testimonial SET testi_status = 'unpublished' WHERE testi_id = $the_testi_id ";
$change_to_sub_query = mysqli_query($connection, $query); }
else if ($the_status='unpublished'){
$query = "UPDATE testimonial SET testi_status = 'published' WHERE testi_id = $the_testi_id ";
$change_to_sub_query = mysqli_query($connection, $query);
}
header("Location: testi.php");
} ?>