Hello,
I have a question about creating a two-week payperiod when inserting a new record for a person. How can i con-figure my code to create a record for a person from a web interface form, without having to create time and date fields on the form??
//My code for inserting a record
<?
$sql = "INSERT INTO stud(name, email, password, phone) VALUES ('$name', '$email', '$password', '$phone')";
$connection = mysql_connect("localhost","univrel","univrel") or die ("Couldn't connect to server.");
$db = mysql_select_db("univrel",$connection) or die ("Couldn't connect to database.");
$sql_result = mysql_query($sql,$connection);
header ("location: records.php3");
?>
//Code to calculate and select the time.
//The dates are pre-set.
//I relate all tables with dateId.
<? session_start(); ?>
<body>
<center>
<form>
<h1>Student Timesheet</h1>
<?
$sql = "SELECT * from st,stud where stud.rowid=st.dateId and stud.name='$name'";
$connection = mysql_connect("localhost","univrel","univrel") or die ("Couldn't connect to server.");
$db = mysql_select_db("univrel",$connection) or die ("Couldn't connect to database.");
$sql_result = mysql_query($sql,$connection);
?>
<table border=\"1\" cellspacing=\"5\" cellpadding=\"3\" width=\"50%\">
<tr>
<td align="center"><b>Pay Period Date</b></td>
<td align="center"><b>Time In:</b></td>
<td align="center"><b>Time Out:</b></td>
<td align="center"><b>Time In:</b></td>
<td align="center"><b>Time Out:</b></td>
<td align="center"><b>Total Hours of Day</b></td>
</tr>
<?
while (($row = mysql_fetch_object($sql_result)))
{
$tarray = explode(":", $row->timeIn_one);
$tone_in = ($tarray[0]60) + $tarray[1];
$tarray = explode(":", $row->timeOut_one);
$tone_out = ($tarray[0]60) + $tarray[1];
$total_timeOne = $tone_out - $tone_in;
$tarray = explode(":", $row->timeIn_two);
$ttwo_in = ($tarray[0]60) + $tarray[1];
$tarray = explode(":", $row->timeOut_two);
$ttwo_out = ($tarray[0]60) + $tarray[1];
$total_timeTwo = $ttwo_out - $ttwo_in;
$totaltime = $total_timeOne + $total_timeTwo;
$hours = $totaltime/60;
$minutes = $totaltime%60;
$formatted_time = "$hours";
$sum += $formatted_time;
// $total contains the hours added together.
printf("<tr>
<td><center>%s</center></td>
<td><center>%s</center></td>
<td><center>%s</center></td>
<td><center>%s</center></td>
<td><center>%s</center></td>
<td><center>%s</center></td>
<td><a href=\"dummylogin.php3?rowid=%s\">Log time</a></td>
</tr>\n", $row->date,
substr($row->timeIn_one,0,strlen($row->timeIn_one)-3),
substr($row->timeOut_one,0,strlen($row->timeOut_one)-3),
substr($row->timeIn_two,0,strlen($row->timeIn_two)-3),
substr($row->timeOut_two,0,strlen($row->timeOut_two)-3),
$formatted_time,
$row->rowid);
}
printf("</table>\n");
print "<br>";
print "Total Pay Period hours:   $sum ";
print "<br><br>";
mysql_free_result($sql_result);
?>
<a href="loginpg.php3">Logoff</a>
</form>
</center>
</body>
Can you help me please??