hello all. here is my code which searches all my record.
<?php
/**
* Main.php
*/
include("include/session.php");
//include("viewproj.php");
?>
<html>
<head>
<title>Export to Excel</title>
</head>
<body>
<form action="searchemp.php" method="post" >
<?php
define ('DB_NAME', 'vincegac_vince');
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
$UserName = $session->username;
$strSQL = "SELECT * FROM employee WHERE projmgr = '$UserName' ";
$rs = mysql_query($strSQL);
?>
<table border="1">
<tr>
<th>Employee Number</th><th>First Name</th><th>Middle Name</th><th>Last Name</th><th>Home Address</th><th>Email Address</th>
<th>Office/project number</th><th>Mobile number</th><th>Home number</th><th>Position</th><th>Practice</th>
<th>Project Name</th><th>Project Manager</th><th>Team Leader</th>
</tr>
<?php
while($row = mysql_fetch_array($rs)) {
?>
<tr>
<td><input name="emp_number" size="10" type="text" value="<?php echo $row['emp_number'] ?>" readonly="readonly"/></td>
<td><input name="fname" size="10" type="text" value="<?php echo $row['fname'] ?>"/></td>
<td><input name="mname" size="10" type="text" value="<?php echo $row['mname'] ?>"/></td>
<td><input name="lname" size="10" type="text" value="<?php echo $row['lname'] ?>" /></td>
<td><input name="homeadd" size="10" type="text" value="<?php echo $row['homeadd'] ?>" /></td>
<td><input name="emailadd" size="10" type="text" value="<?php echo $row['emailadd'] ?>" /></td>
<td><input name="ofcnum" size="10" type="text" value="<?php echo $row['ofcnum'] ?>" /></td>
<td><input name="mobilenum" size="10" type="text" value="<?php echo $row['mobilenum'] ?>" /></td>
<td><input name="homenum" size="10" type="text" value="<?php echo $row['homenum'] ?>" /></td>
<td><input name="position" size="10" type="text" value="<?php echo $row['position'] ?>"/></td>
<td><input name="practice" size="10" type="text" value="<?php echo $row['practice'] ?>" /></td>
<td><input name="projname" size="10" type="text" value="<?php echo $row['projname'] ?>" readonly="readonly"/></td>
<td><input name="projmgr" size="10" type="text" value="<?php echo $row['projmgr'] ?>" readonly="readonly"/></td>
<td><input name="teamlead" size="10" type="text" value="<?php echo $row['teamlead'] ?>" /></td>
<td><input type="submit" name="edit" value="Edit" onclick="this.form.action='update.php'"/></td>
<td><input type="submit" name="del" value="Delete" onclick="this.form.action='delete.php'"/></td>
</tr>
<?php
}
?>
</table>
<?php mysql_close(); ?>
<p><a href="main.php"> Home</a> <a href="demo-form.php"> Add Member</a></p>
</form>
</body>
</html>
and here is my code for update
<?php
define ('DB_NAME', 'vincegac_vince');
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
$empnumber = $_POST["emp_number"];
$fname = $_POST["fname"];
$mname = $_POST["mname"];
$lname = $_POST["lname"];
$homeadd = $_POST["homeadd"];
$emailadd = $_POST["emailadd"];
$ofcnum = $_POST["ofcnum"];
$mobilenum = $_POST["mobilenum"];
$homenum = $_POST["homenum"];
$position = $_POST["position"];
$practice = $_POST["practice"];
$projname = $_POST["projname"];
$projmgr = $_POST["projmgr"];
$teamlead = $_POST["teamlead"];
$sql = "UPDATE employee SET fname = '$fname', mname = '$mname', lname = '$lname', homeadd = '$homeadd', emailadd = '$emailadd', ofcnum = '$ofcnum', mobilenum = '$mobilenum', homenum = '$homenum', position = '$position', practice = '$practice', projname = '$projname', projmgr = '$projmgr', teamlead = '$teamlead'
Where emp_number = '$empnumber'";
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
//echo '<p>One member added! <a href="demo-form.php">add another member</a></p>';
echo 'Record updated!';
echo '<p><a href="main.php">Home page</a></p><p><a href="searchemp.php">Back</a></p>';
mysql_close();
?>
i just want one row to be updated. how is that? :) Thanks you! :)