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: </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?