if($row_number==3 AND $table_row_three>0) { $current_event_2=""; for($d=1; $d<=$table_row_three; $d++) { ?> <tr style="height:16px; width:auto;"> <td> <?php $korbin="SELECT * FROM `calendar_sequence_third` WHERE end_date>= '$the_date' AND date<= '$the_date' and sequence='$d'"; //echo $korbin; $korbin_query=mysqli_query($mysqli, $korbin); $korbin_count=mysqli_num_rows($korbin_query); if($korbin_count>0) { $korbin_row=mysqli_fetch_assoc($korbin_query); if($current_event_2<>$korbin_row['event_id']) { //in order to display the proper start date for events that span multiple days, you've got to find the first day of that sequence $kathy="select date from calendar where event_id='$korbin_row[event_id]' ORDER by date ASC LIMIT 1"; $kathy_query=mysqli_query($mysqli, $kathy); $kathy_row=mysqli_fetch_assoc($kathy_query); $start_date_3=$kathy_row['date']; include('row_three_script_long.php'); $current_event_2=$korbin_row['event_id']; } } $kevin="SELECT * FROM `calendar_sequence_third` WHERE date='$the_date' and end_date='0000-00-00' and sequence='$d'"; //echo $kevin; $kevin_query=mysqli_query($mysqli, $kevin); $kevin_count=mysqli_num_rows($kevin_query); if($kevin_count>0) { //echo $kevin; $kevin_row=mysqli_fetch_assoc($kevin_query); include('row_three_script.php'); } if($kevin_count==0 AND $korbin_count==0) { echo " "; } } }