Jump to content

Recommended Posts

I'm not sure what I'm doing wrong here.

 

I'm trying to get this to show the schedule for each person in the database. It does show the schedule, but it only shows one day in each box, and it's the last day.

 

So, if the last day is October 28th, it populates every box with the schedule for the 28th.

 

<?php

	$query  = "SELECT * FROM employees WHERE day > '$current_date' AND day < '$get_date'";
	$result = mysql_query($query);

	while($row = mysql_fetch_array($result))
	{

		$id = $row['id'];
		$position = $row['position'];
		$pay_rate = $row['pay_rate']; 
		$total_hours = $row['total_hours'];
		$total_pay = $row['total_pay'];
		$start_time = date("g:i a", strtotime($row['start_time']));
		$end_time = date("g:i a", strtotime($row['end_time']));
		$work_day = date("l", strtotime($row['day']));
		$day = date("F j", strtotime($row['day']));
		if($end_time == "24:00:00"){
			$end_time ="Close";};
		$schedule = $start_time ."<br />". $end_time;
		$first = $row['first_n'];
		$last = $row['last_n'];

		if ($work_day == "Monday"){
			$name[$last.", ".$first] = $schedule;
		}
		if ($work_day == "Tuesday"){
			$name[$last.", ".$first] = $schedule;
		}
		if ($work_day == "Wednesday"){
			$name[$last.", ".$first] = $schedule;
		}
		if ($work_day == "Thursday"){
			$name[$last.", ".$first] = $schedule;
		}
		if ($work_day == "Friday"){
			$name[$last.", ".$first] = $schedule;
		}
		if ($work_day == "Saturday"){
			$name[$last.", ".$first] = $schedule;
		}
		if ($work_day == "Sunday"){
			$name[$last.", ".$first] = $schedule;
		}			
}			
foreach ($name as $n => $s)	{			
?>      
      <tr>
        <td align="left" valign="top"><?php echo $n; ?></td>
        <td align="left" valign="top"><?php echo $position; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="center" valign="top"><?php echo $s; ?></td>
        <td align="right" valign="top"> </td>
      </tr>
<?
}
?>

 

Can somebody see what I'm doing wrong?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/216702-simple-or-stupid-not-sure-which/
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.