Jump to content

Simple php display problem.


jbrill

Recommended Posts

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:

Picture4.png

Link to comment
Share on other sites

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>';

Link to comment
Share on other sites

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>';

Link to comment
Share on other sites

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>&nbsp</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

Link to comment
Share on other sites

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>&nbsp</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>';
?>

Link to comment
Share on other sites

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>&nbsp</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>';

 

 

Link to comment
Share on other sites

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>&nbsp</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:

Picture5.png

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.