query($query_s) or die("Błąd zapytania"); $numrows_s = $result_s->num_rows; if ($numrows_s === 0) { header("HTTP/1.0 404 Not Found"); include('./404.php'); die(); } else { while ($row_s = $result_s->fetch_assoc()) { $title = $row_s['tytul_miasto']; $description = $row_s['opis_miasto']; $serviceName = $row_s['nazwa']; $template = file_get_contents('./templates/' . $serviceUrl . '-miasto.html'); } } $cityUrl = $_GET['c']; $query_c = "SELECT * FROM miasta where url = '$cityUrl'"; $result_c = $mysqli->query($query_c) or die("Błąd zapytania"); $numrows_c = $result_c->num_rows; if ($numrows_c === 0) { header("HTTP/1.0 404 Not Found"); include('./404.php'); die(); } else { while ($row_c = $result_c->fetch_assoc()) { $miasto = $row_c["nazwa"]; $miejscownik = $row_c["miejscownik"]; $dopelniacz = $row_c["dopelniacz"]; $miasto_url = $row_c["url"]; $miasto_woj = $row_c["id_woj"]; $miasto_id = $row_c["id"]; } $utm .= $serviceUrl.'_'.$cityUrl; $query2 = "SELECT * FROM uslugi where url != '$serviceUrl'"; $result2 = $mysqli->query($query2) or die("Błąd zapytania"); $numrows2 = $result2->num_rows; $inne_uslugi = ''; while ($row2 = $result2->fetch_assoc()) { $inne_uslugi .= '
  • ' . $row2["nazwa"] . ' w ' . $miejscownik . '
  • '; } $query3 = "SELECT * FROM miasta where id_woj = '$miasto_woj' ORDER BY RAND('$miasto_id') LIMIT $numrows2"; $result3 = $mysqli->query($query3) or die("Błąd zapytania"); $numrows3 = $result2->num_rows; $miasta_w_poblizu = ''; while ($row3 = $result3->fetch_assoc()) { $miasta_w_poblizu .= '
  • ' . $serviceName . ' w ' . $row3["miejscownik"] . '
  • '; } } } elseif (isset($_GET['c']) && !isset($_GET['s'])) { //jeśli dostepny jest wyłącznie parametr c odpowiedzialny za miasto $cityUrl = $_GET['c']; $query = "SELECT * FROM miasta where url = '{$cityUrl}'"; $result = $mysqli->query($query) or die("Błąd zapytania"); $numrows = $result->num_rows; if ($numrows === 0) { header("HTTP/1.0 404 Not Found"); include('./404.php'); die(); } else { while ($row = $result->fetch_assoc()) { $miasto = $row["nazwa"]; $miejscownik = $row["miejscownik"]; $dopelniacz = $row["dopelniacz"]; $miasto_url = $row["url"]; $utm .= $cityUrl; $title = 'Usługi reklamy internetowej w {miejscownik} - Poznaj ofertę'; $description = 'Skuteczne usługi reklamy internetowej w {miejscownik}. Sprawdź ofertę, która będzie dostosowana do Twoich potrzeb i budżetu. Skontaktuj się z nami!'; $template = file_get_contents('./templates/miasto.html'); } } } elseif (isset($_GET['s']) && !isset($_GET['c'])) { //jeśli dostepny jest wyłącznie parametr s odpowiedzialny za usługę $serviceUrl = $_GET['s']; $query = "SELECT * FROM uslugi where url = '{$serviceUrl}'"; $result = $mysqli->query($query) or die("Błąd zapytania"); $row = $result->fetch_assoc(); $numrows = $result->num_rows; if ($numrows === 0) { header("HTTP/1.0 404 Not Found"); include('./404.php'); die(); } else { $title = $row['tytul']; $description = $row['opis']; $template = file_get_contents('./templates/' . $serviceUrl . '.html'); $utm .= $serviceUrl; $query2 = "SELECT * FROM miasta where url IN ('warszawa','krakow','wroclaw','lodz','szczecin','rzeszow','poznan','olsztyn','opole','bialystok','lublin','gdansk','katowice','kielce', 'zielona-gora', 'bydgoszcz', 'torun', 'gorzow-wielkopolski')"; $result2 = $mysqli->query($query2) or die("Błąd zapytania"); $numrows2 = $result2->num_rows; $uslugi_miasta = ''; while ($row2 = $result2->fetch_assoc()) { $uslugi_miasta .= '
  • ' . $row['nazwa'] . ' w ' . $row2["miejscownik"] . '
  • '; } } } $form = ''; require_once("breadcrumbs.php"); $breadcrumbs = breadcrumbs(); $pageurl = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $replace = array('{title}', '{description}', '{miasto}', '{miejscownik}', '{dopelniacz}', '{miasto_url}', '{inne_uslugi}', '{miasta_w_poblizu}', '{breadcrumbs}', '{uslugi_miasta}', '{formularz}', '{url}'); $with = array($title, $description, $miasto, $miejscownik, $dopelniacz, $miasto_url, $inne_uslugi, $miasta_w_poblizu, $breadcrumbs, $uslugi_miasta, $form, $pageurl); $header = file_get_contents('./templates/header.html'); $footer = file_get_contents('./templates/footer.html'); $page = $header . '' . $template . '' . $footer; echo str_replace($replace, $with, $page); ?>