help me please, i need to save the values of everything in the table but the value that can be save is the value of the last record only. i have this code below.
$answer = mysql_query("SELECT * FROM tbl_empinfo where empdept = '$userdept'") or die(mysql_error());
echo "<table border = '1' bordercolor = '#0000FF' align = center cellpadding = 4 cellspacing=0>";
echo "<tr>";
echo "<th><strong><font face = 'Arial' size = 2>ID Number</font></strong></th>";
echo "<th><strong><font face = 'Arial' size = 2>Name</font></strong></th>";
echo "<th align = center><font face = 'Arial' size = 2>Incoming Destination</font></th>";
echo "<th align = center><font face = 'Arial' size = 2>Time In</font></th>";
echo "<th align = center><font face = 'Arial' size = 2>Outgoing Destination</font></th>";
echo "<th align = center><font face = 'Arial' size = 2>Time Out</font></th>";
echo "</tr>";
while($row = mysql_fetch_array($answer))
{
$counter =1;
$counter++;
$name = $row['empname'];
$idno = $row['empidno'];
$shuttle = $row['empshuttle'];
$area = $row['emparea'];
echo "<tr><td><font face=Arial size=2>$idno</font></td>";
echo "<td><font face=Arial size=2>$name</font></td>";
echo "<td><font face=Arial size=2><select name='incdestination' id='incdestination'><option>$shuttle</option>
<option>Alabang</option>
<option>Balibago</option>
<option>Calamba</option>
<option>Carmona</option>
<option>Mayapa</option>
<option>Paseo</option>
</select></font></td>";
$incdestination = $_POST['incdestination'];
echo "<td><select name='timein' id='timein'>
<option>6am</option>
<option>8am</option>
<option>10am</option>
<option>2pm</option>
<option>6pm</option>
<option>8pm</option>
<option>10pm</option>
</select></td>";
$timein = $_POST['timein'];
echo "<td><select name='outdestination' id='outdestination'><option>$shuttle</option>
<option>Alabang</option>
<option>Balibago</option>
<option>Calamba</option>
<option>Carmona</option>
<option>Mayapa</option>
<option>Paseo</option>
</select></font></td>";
$outdestination = $_POST['outdestination'];
echo "<td><select name='timeout' id='timeout'>
<option>6am</option>
<option>8am</option>
<option>10am</option>
<option>2pm</option>
<option>4pm</option>
<option>6pm</option>
<option>8pm</option>
<option>10pm</option>
</select></td></tr>";
$timeout = $_POST['timeout'];
$save = $_POST['save'];
$cancel = $_POST['cancel'];
if ($save == 'Save')
{
$result = mysql_query("SELECT * FROM tbl_shuttledestination WHERE empname = '$name' AND empdate = '$datenow'") or die(mysql_error());
$resultRow = mysql_num_rows($result);
if ($resultRow == '0')
{
mysql_query("INSERT INTO tbl_shuttledestination (empidno, empname, empdept, emparea, empincdest, emptimein, empoutdest, emptimeout, empdate, empflag)
VALUES ('$idno', '$name', '$userdept', '$area', '$incdestination', '$timein', '$outdestination', '$timeout', '$datenow', '0')")
or die(mysql_error());
}
else if ($resultRow != '0')
{
mysql_query("UPDATE tbl_shuttledestination SET empincdest = '$incdestination', emptimein='$timein', empoutdest = '$outdestination', emptimeout = '$timeout' WHERE empdept = '$userdept' AND empdate = '$datenow'") or die(mysql_error());
}
echo "<META HTTP-EQUIV=REFRESH CONTENT='0; URL=http://**.**.***.***/aaaa/bbb/ccc.php'>";
}
else if ($cancel == 'Cancel')
{
echo "<META HTTP-EQUIV=REFRESH CONTENT='0; URL=http://**.**.***.***/aaaa/bbb/ccc.php'>";
exit;
}
}
echo "</table><br/>";
echo "<input name='save' type='submit' id='save' value='Save' />";
echo "<input name='cancel' type='submit' id='cancel' value='Cancel' />";