From c3eff73eccf360e823b759a2699573935f33c2a0 Mon Sep 17 00:00:00 2001 From: "Alfonso Saavedra \"Son Link" Date: Sun, 27 Nov 2022 09:20:37 +0100 Subject: [PATCH] Fix error if no laps --- app/Controllers/Races.php | 12 ++++++++---- app/Views/race.php | 10 +++++++++- public/css/style.css | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/Controllers/Races.php b/app/Controllers/Races.php index 18df86a..41f4ee5 100644 --- a/app/Controllers/Races.php +++ b/app/Controllers/Races.php @@ -29,15 +29,19 @@ class Races extends BaseController $builder = $this->db->table('laps'); $builder->where('race_id', $tplData['race']->id); $query = $builder->get(); - + + $tplData['race']->n_laps = 0; if ($query && $query->getNumRows() > 0) { $tplData['laps'] = json_encode($query->getResult()); - $tplData['user'] = new UsersModel($tplData['race']->user_id); - $tplData['car'] = new CarsModel(getCar($tplData['race']->car_id)); - $tplData['track'] = new TracksModel(getTrack($tplData['race']->track_id)); + $tplData['race']->n_laps = $query->getNumRows(); } + + $tplData['user'] = new UsersModel($tplData['race']->user_id); + $tplData['car'] = new CarsModel(getCar($tplData['race']->car_id)); + $tplData['track'] = new TracksModel(getTrack($tplData['race']->track_id)); } + echo get_header('Races'); echo view('race', $tplData); echo get_footer(['chart.min.js']); diff --git a/app/Views/race.php b/app/Views/race.php index 7a76fbd..e154937 100644 --- a/app/Views/race.php +++ b/app/Views/race.php @@ -30,11 +30,18 @@ getLink() ?> + + Laps completed: + + n_laps ?> + +
+ \ No newline at end of file + + diff --git a/public/css/style.css b/public/css/style.css index 7ef1b8f..135183d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -582,11 +582,11 @@ sd-carcategoryselection { } #open-menu { - background-image: url(/img/menu.svg); + background-image: url('/img/menu.svg'); } #close-menu { - background-image: url(/img/backburger.svg); + background-image: url('/img/backburger.svg'); } #menu {