hi everyone
i m completely fed up to solve dis prob.... i checked my code so many times but i cant find where is my mistake......
plz help me out.....................
I am selecting records from diff tables......my select query is correct and after dat m inserted new record and dat record display on the screen as well as stored in database ...... everything done correct. but i dont want my dropdown values predefined into my html code. i want to get dat value from database table.... and this is the problem which m facing nd failed to find solution.. i tried so many codes but no worked
if i use javascript function den dat will also work predefined ..... is there any function in js to do it...... or something else
CREATE TABLE shift_master (
scode varchar(15) NOT NULL default '',
tin time NOT NULL default '00:00:00',
tout time NOT NULL default '00:00:00',
des varchar(15) NOT NULL default '',
FULLTEXT KEY scode (scode),
FULLTEXT KEY scode_2 (scode),
FULLTEXT KEY scode_3 (scode)
) TYPE=MyISAM;
CREATE TABLE emp_shift (
ecode varchar(15) NOT NULL default '',
edate varchar(15) NOT NULL default '',
scode varchar(15) NOT NULL default ''
) TYPE=MyISAM;
CREATE TABLE emp_company (
ecode varchar(15) NOT NULL default '',
ename varchar(15) NOT NULL default '',
ecom varchar(15) NOT NULL default '',
edoj date NOT NULL default '0000-00-00',
edol date NOT NULL default '0000-00-00',
edpt varchar(15) NOT NULL default '',
esubdpt varchar(15) NOT NULL default '',
eesicode varchar(15) NOT NULL default '',
epf varchar(17) NOT NULL default '',
ecardno varchar(15) NOT NULL default '',
ebank int(15) NOT NULL default '0',
PRIMARY KEY (ecode)
) TYPE=MyISAM;
<?
mysql_connect("localhost","root","root");
mysql_select_db("master");
if($_POST['Submit'])
{
$ecode=$_POST['ecode'];
$edate=$_POST['edate'];
$scode=$_POST['scode'];
mysql_query("INSERT INTO emp_shift VALUES ('$ecode', '$edate', '$scode')");
header("location:empselectshf.php");
exit;
}
$ecode=$_GET['ecode'];
$result=mysql_query("select * from emp_shift where ecode='$ecode'");
$row=mysql_fetch_assoc($result);
mysql_close() ;
?>
<html>
<body bgcolor=E6E6FA>
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<h3> <p align="center"> <font color="160981"> Shift </font></p></h3>
<table align="center" >
<tr> <th>Employee Code </th> <td>
<input name="ecode" type="text" id="ecode" value="<? echo $row['ecode']; ?>"/> </td> </tr>
<tr> <th> Date </th> <td>
<input name="edate" type="text" id="edate" value="<? echo $row['edate']; ?>"/> </td></tr>
<tr> <th> Shift : </th> <td>
<select size="1" name="scode">
<option>morning1</option>
<option>morning2</option>
<option>Afternoon </option>
<option>Afternoon1</option>
</select> </td> </tr>
<tr> <td> <td> <td> <input type="submit" name="Submit" value="Change" /> </td> </tr>
</table>
</form>
</body>
</html>
<html>
<body bgcolor="E6E6FA">
<!--<h3> <p align="center"> Shift Updation Table </p></h3> !-->
<?
$con=mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("master", $con);
$query=mysql_query("SELECT emp_company.ecode, emp_shift.edate ,emp_shift.scode FROM emp_company, emp_shift where emp_company.ecode=emp_shift.ecode ");
echo "<table border='1'><caption> Employee 's Record Updation Table</caption> <BR><BR><BR><BR>
<tr>
<th >Empoyee Code</th>
<th>Date</th>
<th>Shift Code</th>
<th> Update</th>
</tr>" ;
while($row=mysql_fetch_assoc($query))
{
echo "<tr>";
echo "<td>" . $row['ecode'] . "</td>";
echo "<td>" . $row['edate'] . "</td>";
echo "<td>" . $row['scode'] . "</td>";
echo '<td> <a href="empupshf.php?ecode='.$row['ecode'].' "> change Shift </a> </td>' ;
echo "</tr>";
}
mysql_close($con);
?>
</body>
</html>