Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While Updating the category in existing category, should not be displayed in dropdown box

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);
like image 841
Kavya Shrinidhi Avatar asked Oct 29 '22 22:10

Kavya Shrinidhi


2 Answers

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>
like image 190
Haresh Vidja Avatar answered Nov 12 '22 19:11

Haresh Vidja


      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);
  }
}
like image 34
Kavya Shrinidhi Avatar answered Nov 12 '22 19:11

Kavya Shrinidhi