0

如果前一个日期等于当前行的日期,我正在尝试向表格单元格添加一个行跨度。我现在有了它,所以它不显示日期,但我仍然需要它来添加行跨度。

任何帮助将不胜感激。谢谢你。

    //Pull Volunteer Opportunities
$getOpps = mysql_query("SELECT id, group_id, group_name, event_date, max_size, day, meeting_time, avaliable_seats FROM occ_schedule WHERE location_id = '".$location."' ORDER BY event_date") or ("Critical Error! Cannot pull volunteer opportunities"); 

if(mysql_num_rows($getOpps) > 0)
    {
    $prevDate = '';

    while($oppData = mysql_fetch_assoc($getOpps))
        {
        //Check registrations
        $checkReg = mysql_query("SELECT COUNT(id) as totalRegistered FROM occ_volunteers WHERE group_id = '".$oppData['group_id']."'") or die("Critical Error! Cannot check registrations.");

        if(mysql_num_rows($checkReg) > 0)
            {
            while($regData = mysql_fetch_assoc($checkReg))
                {
                if($regData['totalRegistered'] > 0)
                    {
                    $totalRegistered = $regData['totalRegistered'];
                    }

                else
                    {
                    $totalRegistered = '0';
                    }
                }
            }

        $altrow = 'class="alt1"';

        $currentDate = $oppData['event_date'];

        $seatsAvailable = ($oppData['avaliable_seats'] - $totalRegistered);

        if($seatsAvailable > 0)
            {
            $link = '<a href="registerNow.php?id='.$oppData['group_id'].'">Volunteer Now</a>';
            }

        else
            {
            $link = 'All spots have been filled.';
            }

        echo '<tr>';


        if($currentDate == $prevDate)
            {
            echo '<td>&nbsp;</td>';
            }

        else
            {
            echo '<td ' . $altrow . '>' . $oppData['day'] .', ' . date("M d", strtotime($oppData['event_date'])) . '</td>';
            }

        echo '
                <td ' . $altrow . '>'.$oppData['meeting_time'] .'</td>
                <td ' . $altrow . '>'.$totalRegistered . ' of ' . $oppData['avaliable_seats'] .' ' . $link . '</td>
             </tr>';

        $prevDate = $currentDate;
        }
    }
4

0 回答 0