jbrill Posted July 12, 2007 Share Posted July 12, 2007 hey guys, Im trying to create an online time clock for employees to clock in or out throughout the day. Im having problems displaying the employees records though... What i need for it to look like is: Date and then all the "in" and "outs" for that dat in rows beneath. however right now, it is putting every "in" and "out" in a new table... heres my current code, and a image of what im getting right now. <? $result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER BY time"); while($row = mysql_fetch_array($result)) { $date = $row['date']; $status = $row['status']; $time = $row['time']; $notes = $row['notes']; echo '<table bgcolor="#ffffff" class="MainBody1" width="50%" border="0">'; echo '<tr><td colspan="3" align="right" class="underline">Date:'; echo $date; echo '</td></tr>'; echo '<tr>'; echo '<td width="100" align="left">'; echo $status; echo'</td>'; echo '<td width ="150" align="left">'; echo $time; echo'</td>'; echo '<td align="left"> '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; } ?> an this is what im seeing: Quote Link to comment Share on other sites More sharing options...
suma237 Posted July 12, 2007 Share Posted July 12, 2007 add colspan="3" Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 huh? and where I'll give it a try...but i dont think its going to solve my problem Quote Link to comment Share on other sites More sharing options...
suma237 Posted July 12, 2007 Share Posted July 12, 2007 is it solved? Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 nope Quote Link to comment Share on other sites More sharing options...
suma237 Posted July 12, 2007 Share Posted July 12, 2007 can you show an example to me. view of the output? Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 its in the first post, along with the code Quote Link to comment Share on other sites More sharing options...
suma237 Posted July 12, 2007 Share Posted July 12, 2007 echo '<table bgcolor="#ffffff" class="MainBody1" border="0">'; echo '<tr><td colspan="3" align="right" class="underline">Date:'.$date;echo '</td>'; echo '<td align="left" colspan="3">'; echo $status; echo'</td>'; echo '<td align="left" colspan="3">'; echo $time; echo'</td>'; echo '<td align="left" colspan="3"> '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 that still displays like int he photo in the first post Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 in the end i would like it to look liek this photoshoped picture... Quote Link to comment Share on other sites More sharing options...
suma237 Posted July 12, 2007 Share Posted July 12, 2007 try this echo '<table bgcolor="#ffffff" class="MainBody1" border="0">'; echo '<tr><td colspan="3" align="right" class="underline">Date:'.$date;echo '</td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 nope, didnt work... still doesnt gropup all the ins and out's by date Quote Link to comment Share on other sites More sharing options...
tapos Posted July 12, 2007 Share Posted July 12, 2007 Try this: <? $result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER BY time"); $p_date = ""; echo '<table bgcolor="#ffffff" class="MainBody1" width="50%" border="0">'; while($row = mysql_fetch_array($result)) { $date = $row['date']; $status = $row['status']; $time = $row['time']; $notes = $row['notes']; if($p_date == "") $p_date = $date; if($date == $p_date) { echo '<tr><td> </td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; } else { echo '<tr><td colspan="3" align="right" class="underline">Date:'.$date;echo '</td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; } if($p_date != $date) $p_date = $date } echo '</table><br>'; ?> -- Tapos Pal Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 still didnt work... i think something needs to be changed in my query Quote Link to comment Share on other sites More sharing options...
tapos Posted July 12, 2007 Share Posted July 12, 2007 to do your job, the mysql result should have to orderby date. after that try this ? $result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER BY time"); $p_date = ""; echo '<table bgcolor="#ffffff" class="MainBody1" width="50%" border="0">'; while($row = mysql_fetch_array($result)) { $date = $row['date']; $status = $row['status']; $time = $row['time']; $notes = $row['notes']; if($date == $p_date) { echo '<tr><td> </td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; } else { if($p_date == "") $p_date = $date; echo '<tr><td colspan="3" align="right" class="underline">Date:'.$date;echo '</td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; } if($p_date != $date) $p_date = $date } echo '</table><br>'; ?> Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 just tried the above code. here is what i put in: <? $result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER BY time"); $p_date = ""; echo '<table bgcolor="#ffffff" class="MainBody1" width="50%" border="0">'; while($row = mysql_fetch_array($result)) { $date = $row['date']; $status = $row['status']; $time = $row['time']; $notes = $row['notes']; if($date == $p_date) { echo '<tr><td> </td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; } else { if($p_date == "") $p_date = $date; echo '<tr><td colspan="3" align="right" class="underline">Date:'.$date;echo '</td></tr>'; echo'<tr>'; echo '<td >'; echo $status; echo'</td>'; echo '<td >'; echo $time; echo'</td>'; echo '<td > '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; } if($p_date != $date) $p_date = $date } echo '</table><br>'; ?> I got the error: Parse error: syntax error, unexpected '}' in /home/morow/public_html/admin/organize_hours.php on line 178 like 178 is: if($p_date != $date) $p_date = $date } // this is line 178 echo '</table><br>'; Quote Link to comment Share on other sites More sharing options...
chocopi Posted July 12, 2007 Share Posted July 12, 2007 you forgot the ; on $p_date = $date so it should be $p_date = $date; ~ Chocopi Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 12, 2007 Author Share Posted July 12, 2007 ok the code is working now, without errors BUT it is not displaying properly... heres the code now: <? $result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER BY time"); $p_date = ""; echo '<table bgcolor="#ffffff" class="MainBody1" width="50%" border="1">'; while($row = mysql_fetch_array($result)) { $date = $row['date']; $status = $row['status']; $time = $row['time']; $notes = $row['notes']; if($date == $p_date) { echo '<tr><td> </td></tr>'; echo'<tr>'; echo '<td>'; echo $status; echo'</td>'; echo '<td>'; echo $time; echo'</td>'; echo '<td> '; echo $notes; echo'</td>'; echo '</tr>'; } else { if($p_date == "") $p_date = $date; echo '<tr><td colspan="3" align="right" class="underline">Date:'.$date;echo '</td></tr>'; echo'<tr>'; echo '<td>'; echo $status; echo'</td>'; echo '<td>'; echo $time; echo'</td>'; echo '<td> '; echo $notes; echo'</td>'; echo '</tr>'; echo '</table><br>'; } if($p_date != $date) $p_date = $date; } ?> and here is the screenshot: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.