条件中的$ _GET变量

I am struggling a bit with this one. I have this function called getCategories:

Hi. I am struggling a bit with this one. I have this

function getCategories(){
    global $con;
    $q = "SELECT * FROM categories;";
    $result = mysqli_query($con, $q);
    while($row = mysqli_fetch_assoc($result)){
        $category = $row["CategoryName"];
        $sec = htmlspecialchars($category);
        echo " <tr>
        <td>" . $category . "</td>
        <td>
            <a>View</a> |
            <a href=categories.php?task=update&category=" . urlencode($category) . ">Edit</a> |
            <a href=categories.php?task=delete&category=" . urlencode($category) . ">Delete</a>
        </td>
        </tr>";
    }
}

then I have categories.php (the form)

<form action="categories.php" method="POST">
    <p>
        <label for="categoryname">Category Name:&nbsp;</label>
        <input type="text" name="category_name" placeholder="Enter category name" value="<?php echo $editCat?>">
        <?php
            if ($_GET["task"]="") {
                echo "<input type='submit' value='Add Category' name='submit'>";
            } else {
                echo "<input type='submit' value='Update Category' name='update'>";
            }           
        ?>
    </p>
</form>

But when I click the edit button, the script always echo the first one. What should I do?

You can check if task variable is passed in url as query string or not.

<?php
    if (!isset($_GET["task"]) || $_GET["task"] == '') {
        echo "<input type='submit' value='Add Category' name='submit'>";
    } else {
        echo "<input type='submit' value='Update Category' name='update'>";
    }           
?>

if ($_GET["task"]="")

should be

if ($_GET["task"]=="")

because the first one will always return true

You are assigning. You should do comparison, so put this line:

if ($_GET["task"] == "") {

Instead of this line:

if ($_GET["task"]="") {

Update (technical a bit):

What you have written indeed checks if the result of comparison returns true or false, and since in 99.99999% variable assignment operation ends successfully, the first condition always gets passed and the executor never reaches the content of the second condition.