我遇到了问题,如下所示:当用户点击“提交”按钮时,系统必须使用这么多团队填充一个Campaign,每个团队由许多成员组成。到目前为止,这是我的代码:
$query = mysql_query("SELECT sched.cmsName, sched.team, sched.scheduleDate, sched.scheduleInput,emp.empNo FROM tbl_employeeschedules sched
LEFT OUTER JOIN tbl_employees emp ON sched.cmsName = emp.cmsName
WHERE sched.scheduleDate >= '$first' AND sched.scheduleDate < '$seven' AND sched.campaign='$_SESSION[campaign]' GROUP BY sched.team ORDER by sched.team, sched.cmsName") or die(mysql_error());
while($row = mysql_fetch_array($query))
{
$team[$x] = $row['team'];
?>
<th>
TEAM ID:
</th>
<td colspan="9">
<h5> <?php echo $team[$x];//if(isset($_POST['submit'])){if($_SESSION['team']=="Choose..."){echo "";}else{echo $_SESSION['team'];}}else{echo "";} ?> </h5>
</td>
<?php
$query2 = mysql_query("SELECT sched.team, sched.cmsName, sched.scheduleDate, sched.scheduleInput,emp.empNo FROM tbl_employeeschedules sched
LEFT OUTER JOIN tbl_employees emp ON sched.cmsName = emp.cmsName
WHERE sched.scheduleDate >= '$first' AND sched.scheduleDate <= '$seven' AND sched.campaign='$_SESSION[campaign]' AND sched.team='$team[$x]' GROUP BY sched.cmsName") or die(mysql_error());
$y =1;
while($row2 = mysql_fetch_array($query2))
{
$empNo[$y] = $row2['empNo'];
$agent[$y] = $row2['cmsName'];
echo $agent[$y];
$y++;
}
for($y=1;$y<=count($empNo); $y++)
{
$query2 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$first' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query2) == 0)
{
$monday[$y] = "no schedule";
}
else
{
while($row2 = mysql_fetch_array($query2))
{
$monday[$y] = $row2['scheduleInput'];
}
}
$query3 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$second' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query3) == 0)
{
$tuesday[$y] = "no schedule";
}
else
{
while($row3 = mysql_fetch_array($query3))
{
$tuesday[$y] = $row3['scheduleInput'];
}
}
$query4 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$third' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query4) == 0)
{
$wednesday[$y] = "no schedule";
}
else
{
while($row4 = mysql_fetch_array($query4))
{
$wednesday[$y] = $row4['scheduleInput'];
}
}
$query5 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$fourth' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query5) == 0)
{
$thursday[$y] = "no schedule";
}
else
{
while($row5 = mysql_fetch_array($query5))
{
$thursday[$y] = $row5['scheduleInput'];
}
}
$query6 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$fifth' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query6) == 0)
{
$friday[$y] = "no schedule";
}
else
{
while($row6 = mysql_fetch_array($query6))
{
$friday[$y] = $row6['scheduleInput'];
}
}
$query7 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$six' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query7) == 0)
{
$saturday[$y] = "no schedule";
}
else
{
while($row7 = mysql_fetch_array($query7))
{
$saturday[$y] = $row7['scheduleInput'];
}
}
$query8 = mysql_query("SELECT scheduleInput,cmsName FROM tbl_employeeschedules WHERE cmsName='$agent[$y]' AND scheduleDate = '$seven' AND campaign='$_SESSION[campaign]' AND team='$team[$x]'") or die(mysql_error());
if(mysql_num_rows($query8) == 0)
{
$sunday[$y] = "no schedule";
}
else
{
while($row8 = mysql_fetch_array($query8))
{
$sunday[$y] = $row8['scheduleInput'];
}
}
echo"
<tr>
<td class='id'> $empNo[$y] </td>
<td class='agent' colspan='3'> $agent[$y] </td>
<td> <img class='monday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $monday[$y] </td>
<td> <img class='tuesday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $tuesday[$y] </td>
<td> <img class='wednesday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $wednesday[$y] </td>
<td> <img class='thursday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $thursday[$y] </td>
<td> <img class='friday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $friday[$y] </td>
<td> <img class='saturday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $saturday[$y] </td>
<td> <img class='sunday' src='images/grayBox.JPG' style='height:10px;width:8px;'/> $sunday[$y] </td>
</tr>
";
}
$x++;
}
在此代码中:广告系列和小组正确显示,但该成员对其余行显示相同内容。