我正在努力與這一點。 我有這個函數叫getCategories:
嗨。我正在努力與這一點。 我有這個
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>";
}
}
那麼我categories.php
(形式)
<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>
但是,當我點擊編輯按鈕,腳本總是呼應的第一個。我該怎麼辦?
有條件的應該是==,not =。也就是說,如果($ _GET [「任務」] ==「」){' – Tristan
也許這是dastation http://stackoverflow.com/questions/2974011/while-row-mysql-fetch-arrayresult-how-many-loops -are感執行的 –