i need some help from u guys....actually
i have two dynamic drop down list. one is "category" and other is "item"..drop down lists are working fine...but i want is...that when i am selecting value from second drop down...it should be display details of that particular item...
but it doen't...how can i do this....plz help me..
plz see the code below:
Code: Select all
<SCRIPT language="JavaScript">
function reload(form){
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='delete_item.php?cat=' + val;
}
function confirmDelete()
{
return confirm("Are you sure you wish to delete this entry?");
}
</script>
</head>
<?php
include('dbconnect.php');
$category=$_GET['cat'];
$item=$_GET['item'];
$item_id=$_POST['Item_id'];
$item_color=$_POST['Item_color'];
$image=$_FILES['file']['tmp_name'];
$fp = fopen($image, 'r');
$content= 'items/'. $file_name;
$query="select category_name from category_table";
$res=mysql_query($query);
?>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get" enctype="multipart/form-data">
<label for="cat_name">Category Name : </label>
<select name="cat" id="cat" onchange="reload(this.form);">
<option value="selectcategory">Select Category</option>
<?php
while($arr=mysql_fetch_array($res))
{
echo "<option value=\"$arr[0]\""; if ($arr[0]==$category) echo 'selected'; echo ">". $arr[0] ; echo "</option>";
}
?>
</select>
<label for="name">Name : </label>
<select name="item" id="item" >
<option value="selectitem">Select Item</option>
<?php
if(isset($category))
{
$sql="select distinct Item_code from item_table where Item_category='$category'";
$res1=mysql_query($sql);
while($arr1=mysql_fetch_array($res1))
{
echo "<option value=$arr1[0]> $arr1[0] </option>";
}
}
?>
</select><br /><br />
<?php
if(isset($item))
{
$sql1="select * from item_table where Item_code='$item'";
$res2=mysql_query($sql1);
while($arr2=mysql_fetch_array($res2))
{
echo "Item ID : <input name='item_id' value='$arr2[0]' disabled='disabled' /><br /><br />";
echo "Item Code : <input value= '$arr2[1]' /><br /><br />";
echo "Item Color : <input name='item_color' value='$arr2[2]' /><br /><br />";
echo "Item Image : <img value='$arr2[3]' src='$content' width='50px' height='50px' /><br /><br />";
echo "Item Category : <input value='$arr2[4]' /><br /><br />";
}
}
?>
<input type="submit" name="delete" value="Delete Item" onclick="return confirmDelete();"/>
<input type="reset" name="Cancel" value="Cancel" />
</form>
<?php
if(isset($_REQUEST['delete']))
{
$sql2="DELETE FROM item_table WHERE Item_code='$item'";
$res3=mysql_query($sql2);
echo "<br>";
echo "Item Deleted";
}
?>