Hello,
I am building a timesheet consisting of 14-day payperiods. I have created a users table and timesheet table which the timesheet table is working good. The problem i'm having is trying to add new users to the timesheet and when I create new records, i want to create 14day payperiods for the students also by looping to another timesheet by dateId. The users rowid has to equal the timesheet's dateId to retrieve times. How can i create a code new users while adding a 14day payperiod for them??
//user table code
<body>
<center>
<h1>Student Records List</h1>
<?
$sql = "SELECT * from stud";
$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>Name</b></td>
<td align="center"><b>Email Address</b></td>
<td align="center"><b>Password</b></td>
<td align="center"><b>Phone Number</b></td>
<td align="center"><b>Modify/Delete</b></td>
</tr>
<?
while (($row = mysql_fetch_object($sql_result)))
{
printf("<tr>
<td><center>%s</center></td>
<td><center><a href=\"mailto:%s\">%s</a></center></td>
<td><center>%s</center></td>
<td><center>%s</center></td>
<td><a href=\"modify.php3?rowid=%s\"><I>Modify</I></a>|<a href=\"delete.php3?rowid=%s\"><I>Delete</I></a></td>
</tr>\n", $row->name, $row->email, $row->email, $row->password, $row->phone, $row->rowid, $row->rowid);
}
printf("</table>\n");
mysql_free_result($sql_result);
?>
</form>
</center>
</body>
// View timesheet code
<body>
<center>
<form>
<h1>Student Timesheet</h1>
<?
$sql = "SELECT * from st,stud where stud.rowid=st.dateId and stud.name='$PHP_AUTH_USER'";
$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="tsheetloginpg.php3">Logoff</a>
</form>
</center>
</body>
CAN YOU HELP ME!!