我创建了以下程序,用户可以在其中更新列表中的任何特定记录。当用户单击更新按钮时,会打开一个表单,其中包含名称字段、图像字段和用于选择类别的下拉列表。问题是我收到通知:未定义索引:类别错误消息。我试图回应它,但它仍然给我同样的错误信息。我无法理解为什么它没有从下拉列表中获取类别的值。请检查并指导我。
<?php
include 'connect.php';
$sub_category_id= $_GET['sub_category_id'];
$query= "Select * from sub_categories where sub_category_id =$sub_category_id";
$query_run= mysql_query($query);
$fetch= mysql_fetch_array($query_run);
$name= $fetch['sub_category_name'];
$image_query= "select * from sub_categories_images where sub_category_id=$sub_category_id";
$image_query_run= mysql_query($image_query);
$image_query_fetch= mysql_fetch_array($image_query_run);
$image= $image_query_fetch['location'];
echo "
<form action='update_sub_category.php?sub_category_id=$sub_category_id'
method='POST' enctype='multipart/form-data'>
<table border=1>
<tr>
<td>
Sub-Category Name: </td><td> <input type='text' name='sub_category_name' value=$name ></td></tr>
<tr>
<td>
Image1:</td><td> <input type='file' name= 'file' value=$image></td></tr>
</form> </table> ";
/*--------------
Drop Down List
---------------*/
echo "<select name='category'>";
$select_query= 'Select * from category';
$select_query_run = mysql_query($select_query);
while ($select_query_array= mysql_fetch_array($select_query_run) )
{
echo "<option value='".$select_query_array['category_id']."' >"
.htmlspecialchars($select_query_array["name"]).
"</option>";
}
echo "</br>";
$selectTag= "</br><input type='submit' value='Update Product' /></select>";
echo "</div></div>";
echo $selectTag;
echo "</form>";
/*--------------
Drop Down List
---------------*/
$category_tag= $_POST['category'];
/*
$query_sub_category= "update sub_categories set sub_category_name= $name,
category_id= $category where sub_category_id=$sub_category_id ";
*/
?>