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
https://forums.phpfreaks.com/topic/59598-simple-php-display-problem/
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>';

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

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

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

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

 

 

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.