finpuss på søk

This commit is contained in:
Trygve 2025-10-27 23:44:50 +01:00
parent e6d76cd69c
commit a684cb4841
3 changed files with 19 additions and 9 deletions

View File

@ -12,7 +12,12 @@
font-size: 1.4em; font-size: 1.4em;
padding: 1rem; padding: 1rem;
border-radius: var(--bd-radius); border-radius: var(--bd-radius);
width: fit-content;
margin-left: auto;
margin-right: auto;
}
.profile-card h2{
font-size: 2rem;
} }
</style> </style>
</head> </head>
@ -29,7 +34,7 @@
<h1>Søk opp løper</h1> <h1>Søk opp løper</h1>
<form action="/runner.php" method="GET" hx-boost="true" hx-target="#runner_info" hx-swap="show:none"> <form action="/runner.php" method="GET" hx-boost="true" hx-target="#runner_info" hx-swap="show:none">
<label> <label>
Navn eller startnummer Navn, startnummer eller klubb
<input type="text" name="search" id="search"> <input type="text" name="search" id="search">
</label> </label>
<button type="submit">Søk</button> <button type="submit">Søk</button>

View File

@ -65,6 +65,9 @@ function search_for_runner($runner_list, $search_term) {
elseif (str_contains($runner->id, $search_term)){ elseif (str_contains($runner->id, $search_term)){
array_push($filtered_runners, $runner); array_push($filtered_runners, $runner);
} }
elseif (str_contains(strtolower($runner->club), strtolower($search_term))){
array_push($filtered_runners, $runner);
}
} }
return $filtered_runners; return $filtered_runners;

View File

@ -31,12 +31,11 @@ if ($method == "GET") {
$r = $filtered[0]; $r = $filtered[0];
$response .= " $response .= "
<h2> $r->name</h2> <h2> $r->name</h2>
<p> Klubb: $r->club</p> <p> <b>Klubb:</b> $r->club</p>
<p> Løype: $r->course</p> <p> <b>Løype:</b> $r->course</p>
<p> Epost: <a href=\"mailto:$r->email\">$r->email</a></p> <p> <b>Epost:</b> <a href=\"mailto:$r->email\">$r->email</a></p>
<p> Mobilnummer: <a href=\"tel:$r->phone\">$r->phone</a></p> <p> <b>Mobilnummer:</b> <a href=\"tel:$r->phone\">$r->phone</a></p>
<p> Mobilnummer: <a href=\"tel:$r->phone\">$r->phone</a></p> <p> <b>Student?</b> $r->is_student</p>
<p> Student? $r->is_student</p>
"; ";
header("HX-Replace-Url: false"); header("HX-Replace-Url: false");
echo($response); echo($response);
@ -48,8 +47,11 @@ if ($method == "GET") {
$runner = $filtered[$i]; $runner = $filtered[$i];
$response .= "<button class=\"default\" hx-get=\"/runner.php?search=$runner->id\" hx-target=\"#runner_info\" hx-swap=\"show:none\">$runner->id $runner->name</button>"; $response .= "<button class=\"default\" hx-get=\"/runner.php?search=$runner->id\" hx-target=\"#runner_info\" hx-swap=\"show:none\">$runner->id $runner->name</button>";
header("HX-Replace-Url: false"); header("HX-Replace-Url: false");
echo($response);
} }
echo($response);
}
else{
echo("Ingen resultater...");
} }
} }