File "designationMaster.php"

Full Path: /home/krishnamexports/public_html/panel/global_assets/images/designationMaster.php
File size: 4.29 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8

<?php 		  

if(isset($_POST['add']))

{

	$name		= mysqli_real_escape_string($cn,$_POST['name']);																		

	$sql     = mysqli_query($cn, "select * from `tbl_designation` where name='$name'");

	if(mysqli_num_rows($sql)==0)

	{

		$sqlSubject = mysqli_query ($cn,"insert into `tbl_designation` set name='$name'"); 

		if($sqlSubject){

			echo '<div class="alert alert-success"><strong>Success!</strong> Designation Added Successfully.</div>';

		}

		else

		{

			echo '<div class="alert alert-danger"><strong>Danger!</strong> Designation Not Exists.</div>';

		}

	}

	else

	{

		echo '<div class="alert alert-danger"><strong>Danger!</strong> This  Designation Already Exists.</div>';

	}

}





if(isset($_POST['edit']))

{

	$id   	 = $_POST['id'];	 

	$name	 = $_POST['name'];	  	

	$sql     = mysqli_query($cn, "select * from `tbl_designation` where id='$id'");

	$sqlData = mysqli_fetch_array($sql);	

	$sqlSubject = mysqli_query ($cn,"update `tbl_designation` SET name='$name' where `id`='$id'");

	if($sqlSubject)

	{

		echo '<div class="alert alert-success"><strong>Success!</strong> Designation Update Successfully.</div>';

	}

	else

	{

		echo '<div class="alert alert-success"><strong>Warning!</strong> Designation Updated try again.</div>';	

	}

		

}



if(isset($_GET['edit_id']))

{

	$id      = $_GET['edit_id'];

	$sql     = mysqli_query($cn, "select * from `tbl_designation` where id='$id'");

	$sqlData = mysqli_fetch_array ($sql); 

}	



if(isset($_GET['delete_id']))

{

	$id      = $_GET['delete_id'];

	$sql     = mysqli_query($cn, "update `tbl_designation` SET `status`=0 where id='$id'");

	if($sql)

	{

		echo '<div class="alert alert-success"><strong>Success!</strong> Designation Deleted Successfully.</div>';

	}

	else

	{

		echo "error: " . $sql . "<br>" . mysqli_error($conn);	

	}

}

?>			

        

<div class="col-md-12">

  <div class="card">

    <div class="card-body">

      <h4 class="card-title">Designation Master</h4>          

      <form class="forms-sample" method="post" enctype="multipart/form-data">							                

        <div class="row">						                

            <div class="col-md-4">

                <div class="form-group">

                  <label for="exampleInputCity1">Designation</label>

                  <input type="hidden" name="id" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['id'];}?>">

                  <input type="text" class="form-control" name="name" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['name'];}?>" placeholder="Designation Name" required>

                </div>

            </div>						                         

        </div>                 

        <button type="submit" class="btn btn-success mr-2" name="<?php if(isset($_GET['edit_id'])) {echo "edit";}else{ echo "add";}?>">Submit</button>            

      </form>

    </div>

  </div>

</div>

<br><br>



<div class="col-lg-12 grid-margin stretch-card">

	<div class="card">

        <div class="card-body">

          <h4 class="card-title">Designation List</h4>

           <div class="table-responsive">

            <table class="table table-striped">

              <thead>

                <tr>

                  <th>S.No.</th>

                  <th>Designation Image</th>

                  <th>Action</th>

                </tr>

              </thead>

              <tbody>

              <?php

              $i = 1;						  

              $sqlEmployee = mysqli_query($cn, "select * from `tbl_designation` where `status`=1");

              while($sqlEmployeeData = mysqli_fetch_array($sqlEmployee))

			  {?>

                    <tr>

                     <td><?php echo $i++;?></td>                  

                      <td><?php echo $sqlEmployeeData['name'];?></td>                  

                      <td><?php if($i>5){?><a href="home.php?pages=designationMaster&edit_id=<?php echo $sqlEmployeeData['id'];?>">Edit</a> | <a href="home.php?pages=brand&delete_id=<?php echo $sqlEmployeeData['id'];?>" onclick="return deleteConfirm();">Delete</a><?php }?></td>

                    </tr>

              <?php } ?>                          

              </tbody>

            </table>

          </div>

        </div>

	</div>

</div>