<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Asset Tracking & Management System</title>
<link href="css/design.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<?php include "top.php";?>
<?php include "config.php";?>
<body>
<br />
<form name="comp" action="des_action.php" method="post">
<table width="52%" border="1" align="center" class="table">
<tbody>
<tr>
<td colspan="3" class="title">Designation Master</td>
</tr>
<tr>
<td width="28%" class="centertd"><strong>Designation Code <span class="style1"></span></strong></td>
<td width="54%" class="centertd"><strong>Designation Name <span class="style1"></span></strong></td>
<td width="15%" class="centertd"><strong>Add</strong></td>
</tr>
<tr>
<td class="centertd"><input name="desid1" class="text" onblur="checkSpace(this)" onkeypress="return checkRemarks()" size="15" maxlength="99" />
</td>
<td class="centertd"><input name="desname1" class="text" onblur="checkSpace(this)" onkeypress="return checkRemarks()" size="29" maxlength="99" />
</td>
<td class="centertd"><input value="Add" type="submit" name="des" /></td>
</tr>
</tbody>
</table>
<!-- <form name="1" action="des_de_action.php" method="post">-->
<table width="52%" border="1" align="center" class="table">
<tbody>
<tr>
<td colspan="3" class="title">Designation Master</td>
</tr>
<tr>
<td width="28%" class="centertd"><strong>Designation Code <span class="style1"></span></strong></td>
<td width="54%" class="centertd"><strong>Designation Name <span class="style1"></span></strong></td>
<td width="15%" class="centertd"><strong>Select All
<label></label>
</strong></td>
</tr>
<p><br />
<?php
$query="select * from designation";
$exct=mysql_query($query);
// $fet=mysql_fetch_array($exct);
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $exct ))
{
// Print out the contents of each row into a table
?>
<tr>
<td class="centertd"><input name="Descode<?php echo $row['des_id']?>" class="text" value="<?php echo $row['Des_code']?>" size="15" maxlength="99" /></td>
<td class="centertd"><input name="Desname<?php echo $row['des_id']?>" class="text" value="<?php echo $row['Des_name']?>" size="29" maxlength="99" /> </td>
<td class="centertd"><label>
<input type="checkbox" name="checkbox[]" id="checkbox[]" value="<?php echo $row['des_id']?>" />
</label></td>
</tr>
<?php
}
?>
<tr >
<td colspan="3" class="centertd"><label>
<input type="submit" name="des" value="Update" />
<input type="submit" name="des" value="Delete" />
</label></td>
</tr>
</tbody>
</table>
<br />
<br />
<label></label>
<br />
</p>
<p align="center">
<input value="1" type="hidden" name="selected" />
<br />
</p>
</from>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Asset Tracking & Management System</title>
<link href="css/design.css" rel="stylesheet" type="text/css" />
</head>
<?php include "top.php";?>
<?php include "config.php";?>
<body>
<?php
$add=$_POST['des'];
if($add=="Add")
//if($add==)
{
$query="INSERT INTO designation (Des_code,Des_name) VALUES('$POST[desid1]','$POST[desname1]')";
/ $query="INSERT INTO company_master(Company_Name,City,pin,Fax,License_Number,Mail_server,Emil_ID,Address1,Address2,Country,Phone,License_date,SMTP_port,CG_value) VALUES
('$POST[companyName]','$POST[city]','$POST[pin]','$POST[fax]','$POST[license_no]','$POST[host]','$POST[mail]','$POST[Address1]','$POST[Address2]','$POST[country]','$POST[phone]','$POST[enDate]','$POST[port]','$POST[strUtilized_cgVal]')"; /
mysql_query($query);
?>
<script>
alert("Added Successfully");
location.href="Deisgnation_master.php";
</script>
<?php
}
if($add=="Delete")
{
$checkbox = $POST['checkbox']; //from name="checkbox[]"
$countCheck = count($POST['checkbox']);
for($i=0;$i<$countCheck;$i++)
{
$del_id = $checkbox[$i];
$sql = "DELETE from designation where des_id = '$del_id'";
// $result = $mysqli->query($sql) or die(mysqli_error($mysqli));
$result =mysql_query($sql) or die(mysql_error());
}
if($result)
{
//header('Location: index.php');
}
else
{
echo "Error: ".mysql_error();
}
?>
<script>
alert("Deleted Successfully");
location.href="Deisgnation_master.php";
</script> <?php
}
if($add=="Update")
{
$descode=$POST['Descode'];
$desname=$POST['Desname'];
//from name="checkbox[]"
$checkbox = $POST['checkbox'];
// $countCheck = count($POST['checkbox']);
$countCheck = count(isset($_POST['checkbox']));
for($i=0;$i<$countCheck;$i++)
{
$delid=$checkbox[$i];
//$sql = "Update designation set where des_id = '$del_id'";
// $result = $mysqli->query($sql) or die(mysqli_error($mysqli));
//echo"UPDATE designation SET Des_code='$descode', Des_name='$desname' where des_id='$delid[$i]'";
$sql="UPDATE designation SET Des_code='$descode', Des_name='$desname' where des_id='$delid'";
// $sql = "update designation set Des_code = '".$POST['Descode'.$i]."', Des_name = '".$POST['Desname'.$i]."' where des_id='$delid[$i]'";
$result =mysql_query($sql) or die(''.mysql_error());
}
if(!$result)
{
die('not updated'.mysql_error());
}
else
{
echo "sucess fully updated";
}
?>
<script>
alert("Updated Successfully");
location.href="Deisgnation_master.php";
</script> <?php
}
?>
</body>
</html>