Foppe Hemminga 6 лет назад
Родитель
Сommit
97ad160c5a
1 измененных файлов с 20 добавлено и 12 удалено
  1. 20 12
      index.php

+ 20 - 12
index.php

@@ -44,19 +44,31 @@
         </thead>
         <tbody>
 TABLEHEAD;
+	$table_foot = <<<TABLEFOOT
+        </tbody>
+    </table>
+TABLEFOOT;
     echo( $table_head );
     $new_venue = '';
     $new_day = '';
     while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : ?>
         <?php
-            if ( $new_day != '' && $new_day != $row['race_date'] ) {
-                echo $table_foot;
-                echo '<h4>' . htmlspecialchars($row['race_date']) . '</h4>';
-                echo $table_head;
-            } else if ( $new_venue != '' && $new_venue != $row['venue'] ) {
-                echo $table_foot;
-                echo $table_head;
-                $new_venue = $row['venue'];
+            if ( $new_day != '' ) {
+				if ($new_day != $row['race_date']) {
+					echo $table_foot;
+					echo '<h4>' . htmlspecialchars($row['race_date']) . '</h4>';
+					echo $table_head;
+				}
+			} else {
+				$new_day = $row['race_date'];
+            }
+            if ( $new_venue != '' ) {
+                if ($new_venue != $row['venue'] ) {
+					echo $table_foot;
+					echo $table_head;
+				}
+            } else {
+				$new_venue = $row['venue'];
             }
         ?>
     <tr>
@@ -68,10 +80,6 @@ TABLEHEAD;
     </tr>
 	<?php endwhile; ?>
     <?php
-    $table_foot = <<<TABLEFOOT
-        </tbody>
-    </table>
-TABLEFOOT;
     echo $table_foot;
 
     }catch (PDOException $e){