kashif
Monday, 14 December 2015
Adding a column's value in a Listbox using php
<?php
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection!");
mysql_select_db("attendencedb",$A) or die("Error in DataBase!");
$NA = mysql_query("SELECT concat(FirstName, ' ' , LastName) as Name FROM tblstudent") or die("Error in Selecting ID...!");
?>
<select name="dynamic_data">
<?php
$i=0;
while($row = mysql_fetch_array($NA)) {
?>
<option value="<?=$row["Name"];?>"><?=$row["Name"];?></option>
<?php
$i++;
}
?>
</select>
<?php
mysql_close($A);
?>
Sunday, 6 December 2015
Payroll Management
Login Form:
<?php
if(isset($_POST['btnlogin']))
{
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
$NM = $_POST['txtName'];
$RN = $_POST['txtRegno'];
$query = mysql_query("SELECT * FROM tblemp where FirstName='".$NM."' AND RegNo='".$RN."'", $A) or die("Error in Select Query");
$row = mysql_fetch_array($query);
if($row["FirstName"]==$NM && $row["RegNo"]==$RN)
{
echo "<script> window.location.assign('index.php'); </script>";
echo "<a href='index.php?A=$rec[1] &B=$rec[3]></a></td>";
}
else
{
echo "<script>";
echo 'alert("Your Name OR Reg No is wrong...!")';
echo"</script>";
}
mysql_close($A);
}
?>
<div class="login-header text-center">
<br><br>
<img src="assets/img/team-back1.jpg">
</div>
<div class="login-wrapper">
<form action="login.php" method="post">
<div class="form-group has-feedback lg left-feedback no-label">
<input type="text" name="txtName" placeholder="Enter FirstName" autofocus required>
<span class="fa fa-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback lg left-feedback no-label">
<input type="password" name="txtRegno" placeholder="Enter Reg.No" required>
<span class="fa fa-unlock-alt form-control-feedback"></span>
</div>
<div class="form-group">
</div>
<div class="form-group">
<button type="submit" name="btnlogin" >LOGIN</button>
</div>
</form>
</div><!-- /.login-wrapper -->
Add Employee:
<?php
if(isset($_POST['btnReg']))
{
$NM = $_POST['txtName'];
$LN = $_POST['txtLName'];
$UI = $_FILES['UImg']['name'];
$FT = $_FILES['UImg']['type'];
$FN = $_POST['txtFName'];
$CC = $_POST['txtNIC'];
$PN = $_POST['telno'];
$AD = $_POST['txtadres'];
$DB = $_POST['DOB'];
$GN = $_POST['rdoGend'];
$JD = $_POST['JDate'];
$RL = $_POST['lstRlgn'];
$DG = $_POST['txtDesg'];
$DP = $_POST['lstDept'];
$ST = $_POST['txtStatus'];
$RN = $_POST['txtRegno'];
if($FT =="image/jpeg" || $FT == "image/gif" || $FT=="image/png")
{
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
mysql_query("Insert into tblemp values ('','$NM','$LN','$UI','$FN','$CC','$PN','$AD','$DB','$GN','$JD','$RL','$DG','$DP','$ST','$RN')", $A) or die("Error in Insert Query");
mysql_close($A);
echo '<script language="javascript">';
echo 'alert("Registered Successfuly...!")';
echo '</script>';
}
else
{
echo "Error: Select jpg | gif | png image.";
}
}
?>
<p>Begin your Registration here</p>
<!-- Begin basic form elements -->
<div class="row">
<div class="col-sm-6">
<!-- Begin basic form elements -->
<div class="the-box">
<h4 class="small-title">Employee's Information</h4>
<form action="add-emp.php" method="POST" Enctype="multipart/form-data">
<div class="form-group">
<label>First Name</label>
<input type="text" name="txtName" class="form-control rounded" placeholder="Enter First Name" required>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="txtLName" class="form-control rounded" placeholder="Enter Last Name" required>
</div>
<div class="form-group">
<label>Upload Image</label>
<div class="input-group">
<input type="file" name="UImg" required>
</div><!-- /.input-group -->
</div>
<div class="form-group">
<label>Father Name</label>
<input type="text" name="txtFName" class="form-control rounded" placeholder="Enter Father Name" required>
</div>
<div class="form-group">
<label>NIC No</label>
<input type="text" name="txtNIC" class="form-control rounded" placeholder="Enter NIC No" required>
</div>
<div class="form-group">
<label>Phone No</label>
<input type="text" name="telno" class="form-control rounded" placeholder="Enter Phone No" required>
</div>
<div class="form-group">
<label>Address</label>
<textarea name="txtadres" class="form-control rounded no-resize bold-border" required></textarea>
</div>
<div class="form-group">
<label>Date of Birth</label>
<input type="date" name="DOB" class="form-control rounded" data-date-format="mm-dd-yy" placeholder="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Gender</label>
<div class="radio">
<label>
<input type="radio" name="rdoGend" id="optionsRadios1" value="Male" checked>
Male
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="rdoGend" id="optionsRadios2" value="Female">
Female
</label>
</div>
</div>
<div class="form-group">
<label>Joining Date</label>
<input type="date" name="JDate" class="form-control rounded" data-date-format="mm-dd-yy" placeholder="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Religion</label>
<select name="lstRlgn" class="form-control rounded">
<option value="Islam">Islam</option>
<option value="Baha’i Faith">Baha’i Faith</option>
<option value="Buddhism">Buddhism</option>
<option value="Christianity">Christianity</option>
<option value="Confucianism">Confucianism</option>
<option value="Hinduism">Hinduism</option>
<option value="Jainism">Jainism</option>
<option value="Judaism">Judaism</option>
<option value="Shinto">Shinto</option>
<option value="Sikhism">Sikhism</option>
<option value="Taoism">Taoism</option>
<option value="Zoroastrianism">Zoroastrianism</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<label>Designation</label>
<input type="text" name="txtDesg" class="form-control rounded" placeholder="Enter Designation" required>
</div>
<div class="form-group">
<label>Department</label>
<select name="lstDept" class="form-control rounded">
<option value="Customer Services">Customer Services</option>
<option value="Financial">Financial</option>
<option value="Human Resources">Human Resources</option>
<option value="Information Technology">Information Technology</option>
<option value="Inventory">Inventory</option>
<option value="Insuarence">Insuarence</option>
<option value="Licences">Licences</option>
<option value="Marketing">Marketing</option>
<option value="Operational">Operational</option>
<option value="Organizational">Organizational</option>
<option value="Purchasing">Purchasing</option>
<option value="Quality Asuarence">Quality Asuarence</option> <option value="Sales">Sales</option>
<option value="Staff">Staff</option>
<option value="Other Services">Other Services</option>
</select>
</div>
<div class="form-group">
<label>Working Status</label>
<input type="text" name="txtStatus" class="form-control rounded" placeholder="Enter Working Status" required>
</div>
<div class="form-group">
<label>Registration No</label>
<input type="text" name="txtRegno" class="form-control rounded" placeholder="Enter Registration No" required>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="btnReg" value="Register">
</div>
</form>
</div><!-- /.the-box -->
<!-- End basic form elements -->
</div>
Search Employee:
<form method="get" action="Search-Emp.php" class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Enter First Name">
<input type="submit" name="submit" value="Search">
</div>
</form>
<br><br><br>
<!-- Begin basic form elements -->
<div class="row">
<div class="col-sm-6">
<table border=1>
<tr bgcolor="#CC99CC">
<th>Emp ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Image</th>
<th>Father Name</th>
<th>NIC</th>
<th>Phone Number</th>
<th>Address</th>
<th>Date Of Birth</th>
<th>Gender</th>
<th>Joining Date</th>
<th>Religion</th>
<th>Designation</th>
<th>Department</th>
<th>Working Status</th>
<th>Reg.No</th>
<th>Salary Slip</th>
</tr>
<?php
if (isset($_GET['name']))
{
$letter = $_GET['name'];
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection!");
mysql_select_db("payroldb",$A) or die("Error in DataBase!");
$B = mysql_query("Select * from tblemp where FirstName like '%".$letter."%' || LastName like '%".$letter."%' || FatherName like '%".$letter."%' || Address like '%".$letter."%'",$A) or die("Error in Insert Query.");
$num_rows = mysql_num_rows($B);
if($num_rows == 1){
echo "<h2> $num_rows Employee </h2>";
}
else
echo "<h2> $num_rows Employees </h2>";
for($a=0; $a<$num_rows; $a++)
{
$rec = mysql_fetch_array($B);
echo "<tr>";
echo "<td>$rec[0]</td>";//EID
echo "<td>$rec[1]</td>";//First Name
echo "<td>$rec[2]</td>";//Last Name
echo "<td><img src='images/$rec[3]' width=50 height=50 border=5 Title='$rec[1]'></td>";//Image
echo "<td>$rec[4]</td>";//Father Name
echo "<td>$rec[5]</td>";//NIC
echo "<td>$rec[6]</td>";//Ph.No
echo "<td>$rec[7]</td>";//Address
echo "<td>$rec[8]</td>";//DOB
echo "<td>$rec[9]</td>";//Gender
echo "<td>$rec[10]</td>";//Joining Date
echo "<td>$rec[11]</td>";//Religion
echo "<td>$rec[12]</td>";//Designation
echo "<td>$rec[13]</td>";//Department
echo "<td>$rec[14]</td>";//Working Status
echo "<td>$rec[15]</td>";//Reg No
echo "<td><a href='SalarySlip.php?A=$rec[0]'>Salary Slip</a></td>";
echo "</tr>";
}
mysql_close($A);
}
?>
</table>
</div><!-- /.col-sm-6 -->
Update Employee:
<div class="row">
<div class="col-sm-6">
<!-- Begin basic form elements -->
<div class="the-box">
<h4 class="small-title">Employee's Information</h4>
<form action="Update-emp.php" method="POST" Enctype="multipart/form-data">
<div class="form-group">
<label>ID</label>
<input type="text" name="txtID" class="form-control rounded" Value="<?php echo $_GET['A'] ?>" readonly>
</div>
<div class="form-group">
<label>First Name</label>
<input type="text" name="txtName" class="form-control rounded" Value="<?php echo $_GET['B'] ?>" required>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="txtLName" class="form-control rounded" Value="<?php echo $_GET['C'] ?>" required>
</div>
<div class="form-group">
<label>Image</label>
<input type="text" name="txtUImg" class="form-control rounded" Value="<?php echo $_GET['D'] ?>" required>
</div>
<div class="form-group">
<label>Father Name</label>
<input type="text" name="txtFName" class="form-control rounded" Value="<?php echo $_GET['E'] ?>" required>
</div>
<div class="form-group">
<label>NIC No</label>
<input type="text" name="txtNIC" class="form-control rounded" Value="<?php echo $_GET['F'] ?>" required>
</div>
<div class="form-group">
<label>Phone No</label>
<input type="text" name="telno" class="form-control rounded" Value="<?php echo $_GET['G'] ?>" required>
</div>
<div class="form-group">
<label>Address</label>
<input type="text" name="txtadres" class="form-control rounded" Value="<?php echo $_GET['H'] ?>" required>
</div>
<div class="form-group">
<label>Date of Birth</label>
<input type="text" name="DOB" class="form-control rounded" Value="<?php echo $_GET['I'] ?>" data-date-format="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Gender</label>
<input type="text" name="rdoGend" class="form-control rounded" value="<?php echo $_GET['J']?>" required>
</div>
<div class="form-group">
<label>Joining Date</label>
<input type="text" name="JDate" class="form-control rounded" Value="<?php echo $_GET['K'] ?>" data-date-format="mm-dd-yy" required>
</div>
<div class="form-group">
<label>Religion</label>
<input type="text" name="lstRlgn" class="form-control rounded" Value="<?php echo $_GET['L'] ?>">
</div>
<div class="form-group">
<label>Designation</label>
<input type="text" name="txtDesg" class="form-control rounded" Value="<?php echo $_GET['M'] ?>" required>
</div>
<div class="form-group">
<label>Department</label>
<input type="text" name="lstDept" class="form-control rounded" Value="<?php echo $_GET['N'] ?>">
</div>
<div class="form-group">
<label>Working Status</label>
<input type="text" name="txtStatus" class="form-control rounded" Value="<?php echo $_GET['O'] ?>" required>
</div>
<div class="form-group">
<label>Registration No</label>
<input type="text" name="txtRegno" class="form-control rounded" Value="<?php echo $_GET['P'] ?>" required>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="btnUpdate" value="Update">
<input class="btn btn-primary" type="button" onClick="Back()" value="Back">
</div>
</form>
<script>
function Back()
{
document.location.href='view-emp.php';
}
</script>
</div><!-- /.the-box -->
<!-- End basic form elements -->
</div><!-- /.col-sm-6 -->
<?php
if(isset($_POST['btnUpdate']))
{
$ID = $_POST['txtID'];
$NM = $_POST['txtName'];
$LN = $_POST['txtLName'];
$IM = $_POST['txtUImg'];
$FN = $_POST['txtFName'];
$CC = $_POST['txtNIC'];
$PN = $_POST['telno'];
$AD = $_POST['txtadres'];
$DB = $_POST['DOB'];
$GN = $_POST['rdoGend'];
$JD = $_POST['JDate'];
$RL = $_POST['lstRlgn'];
$DG = $_POST['txtDesg'];
$DP = $_POST['lstDept'];
$ST = $_POST['txtStatus'];
$RN = $_POST['txtRegno'];
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
mysql_query("Update tblemp set FirstName='$NM', LastName='$LN',Image='$IM', FatherName='$FN', NIC='$CC', PhoneNo='$PN', Address='$AD', DOB='$DB', Gender='$GN', JoiningDate='$JD', Religion='$RL', Designation='$DG', Department= '$DP', WorkingStatus='$ST', RegNo='$RN' Where ID='$ID'", $A) or die("Error in Update Query");
mysql_close($A);
echo '<script language="javascript">';
echo 'alert("Updated Successfuly...!")';
echo '</script>';
}
?>
View Employee:
<?php
if(isset($_GET['A']))
{
$P = $_GET['A'];
$A = mysql_connect("localhost","root","") or die ("error in sql connection");
mysql_select_db("payroldb",$A) or die ("error in database");
mysql_query("delete from tblemp Where ID=$P",$A) or die ("error in query");
mysql_close($A);
}
?>
<?php
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection!");
mysql_select_db("payroldb",$A) or die("Error in DataBase!");
$B = mysql_query("Select * from tblemp",$A) or die("Error in Select Query.");
$num_rows = mysql_num_rows($B);
if($num_rows == 1)
{
echo "<h2> $num_rows Employee </h2>";
}
else
{
echo "<h2> $num_rows Employees </h2>";
}
?>
<p style="color:#F00">Click on the First Name to edit the employee's Information...!</p>
&
<p style="color:#F00">Click on the Last Name to delete the employee's Information...!</p>
<table border="1">
<thead bgcolor="#FFFFFF">
<tr>
<th>Emp ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Image</th>
<th>Father Name</th>
<th>NIC</th>
<th>Phone Number</th>
<th>Address</th>
<th>Date Of Birth</th>
<th>Gender</th>
<th>Joining Date</th>
<th>Religion</th>
<th>Designation</th>
<th>Department</th>
<th>Working Status</th>
<th>Reg.No</th>
</tr>
</thead>
<?php
for($a=0; $a<$num_rows; $a++)
{
$rec=mysql_fetch_array($B);
echo "<tr>";
echo "<td>$rec[0]</td>";//EID
echo "<td><a href='Update-emp.php?A=$rec[0] &B=$rec[1] &C=$rec[2] &D=$rec[3] &E=$rec[4] &F=$rec[5] &G=$rec[6] &H=$rec[7] &I=$rec[8] &J=$rec[9] &K=$rec[10] &L=$rec[11] &M=$rec[12] &N=$rec[13] &O=$rec[14] &P=$rec[15]'>$rec[1]</a></td>";//First Name?>
<td><a onClick="return confirm('Are you sure you want to delete this record?')"
href='view-emp.php?A=<?php echo $rec[0] ?>'><?php echo " $rec[2]" ?></a></td><?php //Last Name
echo "<td><img src='images/$rec[3]' width=50 height=50 border=5 Title='$rec[1]'></td>";//Image
echo "<td>$rec[4]</td>";//Father Name
echo "<td>$rec[5]</td>";//NIC
echo "<td>$rec[6]</td>";//Ph.No
echo "<td>$rec[7]</td>";//Address
echo "<td>$rec[8]</td>";//DOB
echo "<td>$rec[9]</td>";//Gender
echo "<td>$rec[10]</td>";//Joining Date
echo "<td>$rec[11]</td>";//Religion
echo "<td>$rec[12]</td>";//Designation
echo "<td>$rec[13]</td>";//Department
echo "<td>$rec[14]</td>";//Working Status
echo "<td>$rec[15]</td>";//Reg No
echo "</tr>";
}
mysql_close($A);
?>
</table>
Monday, 30 November 2015
Reading and printing a (.txt) file on web page in PHP & Save the data to Database
<?php
$myfile = fopen("time.txt", "r") or die("Unable to open file!");
while(!feof($myfile)) {
$x = fgets($myfile);
echo $x;
echo "<br>"; //save it to DB
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection");
mysql_select_db("payroldb",$A) or die("Error in Data Base");
mysql_query("insert into tbltime values('','".$x."','".$x."')",$A) or die("Error in insert query!");
mysql_close($A);
}
fclose ($myfile);
?>
Confirm Message at Delete button
HTML Code:
<td><a onClick="return confirm('Are you sure you want to delete this record?')"
href='view-emp.php?A=<?php echo $rec[0] ?>'><?php echo " $rec[2]" ?></a></td>
PHP Code:
<?php
if(isset($_GET['A']))
{
$P = $_GET['A'];
$A = mysql_connect("localhost","root","") or die ("error in sql connection");
mysql_select_db("payroldb",$A) or die ("error in database");
mysql_query("delete from tblemp Where ID=$P",$A) or die ("error in query");
mysql_close($A);
}
?>
Thursday, 26 November 2015
File upload and move to folder
Index Page/Main Page/Form:
<html>
<head>
<title>Upload File</title>
</head>
<body>
<table align="center">
<tr>
<td><fieldset>
<legend>Upload File</legend>
<form action="upload.php" method="POST" Enctype="multipart/form-data">
<input type="file" name="file"><br><br>
<input type="Submit" name="btnSave" value="Upload">
</form></fieldset>
</td></tr>
<tr>
<td></td>
</tr>
</table>
</body>
</html>
Description Page with PHP code:
<html>
<head>
<title>Description</title>
</head>
<body>
<table align="center">
<tr><td>
<?php
if (isset($_POST['btnSave'])){
if(!file_exists("upload"))
{
mkdir("upload");
}
if($_FILES["file"]["error"] > 0)
{
$er="ERROR Return Code:".$_FILES["file"]["error"]."<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
$file = $_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$_FILES["file"]["name"]);
echo "Stored in" , " upload/" , $_FILES["file"]["name"];
}
}
?>
<br>
<a href="indexx.php">Back</a>
<?php
//echo $er;
?>
</td></tr>
</table>
</body>
</html>
Captcha
<html>
<head>
<title>Captcha Validation</title>
<script type="text/javascript">
function DrawCaptcha()
{
var a = Math.ceil(Math.random() * 10)+ '';
var b = Math.ceil(Math.random() * 10)+ '';
var c = Math.ceil(Math.random() * 10)+ '';
var d = Math.ceil(Math.random() * 10)+ '';
var e = Math.ceil(Math.random() * 10)+ '';
var f = Math.ceil(Math.random() * 10)+ '';
var g = Math.ceil(Math.random() * 10)+ '';
var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
document.getElementById("txtCaptcha").value = code
}
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
if (str1 == str2) return true;
return false;
}
function removeSpaces(string)
{
return string.split(' ').join('');
}
</script>
</head>
<body onload="DrawCaptcha();">
<div class="align">
Welcome To Captcha<br />
<input id="txtCaptcha" type="text" readonly="" class="input_img">
<input type="button" id="btnrefresh" value="Refresh" onclick="DrawCaptcha();" /><br>
<input type="text" id="txtInput"/>
<input id="Button1" type="button" value="Check" onclick="alert(ValidCaptcha());"/>
</div>
<p style="color:#F36">- See more at: http://codingresolved.com/discussion/540/how-to-make-captcha-in-javascript/p1#sthash.3nlKLUxl.dpuf</p>
</body>
</html>
<head>
<title>Captcha Validation</title>
<script type="text/javascript">
function DrawCaptcha()
{
var a = Math.ceil(Math.random() * 10)+ '';
var b = Math.ceil(Math.random() * 10)+ '';
var c = Math.ceil(Math.random() * 10)+ '';
var d = Math.ceil(Math.random() * 10)+ '';
var e = Math.ceil(Math.random() * 10)+ '';
var f = Math.ceil(Math.random() * 10)+ '';
var g = Math.ceil(Math.random() * 10)+ '';
var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
document.getElementById("txtCaptcha").value = code
}
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
if (str1 == str2) return true;
return false;
}
function removeSpaces(string)
{
return string.split(' ').join('');
}
</script>
</head>
<body onload="DrawCaptcha();">
<div class="align">
Welcome To Captcha<br />
<input id="txtCaptcha" type="text" readonly="" class="input_img">
<input type="button" id="btnrefresh" value="Refresh" onclick="DrawCaptcha();" /><br>
<input type="text" id="txtInput"/>
<input id="Button1" type="button" value="Check" onclick="alert(ValidCaptcha());"/>
</div>
<p style="color:#F36">- See more at: http://codingresolved.com/discussion/540/how-to-make-captcha-in-javascript/p1#sthash.3nlKLUxl.dpuf</p>
</body>
</html>
Tuesday, 17 November 2015
Search Box code in PHP
HTML Tags:
<form method="get" action="Search-Emp.php" class="navbar-form navbar-left" role="search">
<input type="text" name="name" class="form-control" placeholder="Search">
<input type="submit" name="submit" value="Search">
</form>
<br><br><br>
<table border=1>
<tr bgcolor="#CC99CC">
<th>Emp ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Image</th>
<th>Father Name</th>
<th>NIC</th>
<th>Phone Number</th>
<th>Address</th>
<th>Date Of Birth</th>
<th>Gender</th>
<th>Joining Date</th>
<th>Religion</th>
<th>Designation</th>
<th>Department</th>
<th>Working Status</th>
<th>Reg.No</th>
</tr>
</table>
PHP Code:
<?php
if (isset($_GET['name']))
{
$letter = $_GET['name'];
$A = mysql_connect("LocalHost","root","") or die("Error in MYSQL Connection!");
mysql_select_db("payroldb",$A) or die("Error in DataBase!");
$B = mysql_query("Select * from tblemp where FirstName like '%".$letter."%'",$A) or die("Error in Insert Query.");
$num_rows = mysql_num_rows($B);
if($num_rows == 1){
echo "<h2> $num_rows Employee </h2>";
}
else
echo "<h2> $num_rows Employees </h2>";
for($a=0; $a<$num_rows; $a++)
{
$rec = mysql_fetch_array($B);
echo "<tr>";
echo "<td>$rec[0]</td>";//EID
echo "<td>$rec[1]</a></td>";//First Name
echo "<td>$rec[2]</td>";//Last Name
echo "<td><img src='images/$rec[3]' width=50 height=50 border=5 Title='$rec[1]'></td>";//Image
echo "<td>$rec[4]</td>";//Father Name
echo "<td>$rec[5]</td>";//NIC
echo "<td>$rec[6]</td>";//Ph.No
echo "<td>$rec[7]</td>";//Address
echo "<td>$rec[8]</td>";//DOB
echo "<td>$rec[9]</td>";//Gender
echo "<td>$rec[10]</td>";//Joining Date
echo "<td>$rec[11]</td>";//Religion
echo "<td>$rec[12]</td>";//Designation
echo "<td>$rec[13]</td>";//Department
echo "<td>$rec[14]</td>";//Working Status
echo "<td>$rec[15]</td>";//Reg No
echo "</tr>";
}
mysql_close($A);
}
?>
Subscribe to:
Posts (Atom)