Iam trying to create a dropdown box for blog category using php and while editing the category form it should not be display the existing category name which i need to update in category form.
Example i have a product electronics under that category i have laptop and mobile , if i update mobile in dropdown box mobile option should not be displayed Thanks in advance
The form look like this now
The second form in which i highlighten "laptop" Keyword , while editing it should not be displayed
<select name="category" class="field" style="width:160px" >
<option value="0">Select</option>
{var name='cat_ops'}
</select>
if ($_GET['action'] == 'edit' && $_GET['id']) {
$sel_cat =$cate_id ;
} else {
$sel_cat = "";
}
construct_cat_ops($sel_cat);
$tmpl->setvar('cat_ops', $cat_ops);
I think your code should be, anyway i dont know php code is in separate file and html/tpl code in separate file.
if ($_GET['action'] == 'edit' && $_GET['id']) {
$sel_cat =$cate_id ;
} else {
$sel_cat = "";
}
construct_cat_ops($sel_cat);
$tmpl->setvar('cat_ops', $cat_ops);
<select name="category" class="field" style="width:160px" >
<option value="0">Select</option>
{var name='cat_ops'}
</select>
if ($_POST['update'] && $_POST['hid_id']) {
if($brand==$categoryname){
$msg = "Parent category cannot be same";
$tmpl->setvar('msg_err', $msg);
}else{
$db->query("Update `blog_category` set`name`='$brand',`parent`='$category' where id='" . $_POST['hid_id'] . "'");
$msg = "Blog category Updated Successfully";
$tmpl->setvar('msg_ok', $msg);
$tmpl->setvar('name', $brand);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With