Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Nabend,

ich habe ein fix und fertiges script, dass Daten aus meiner Datenbank abfragt und die Ergebnisse in einer Tabelle anzeigt.

Leider kann nur in der Suchmaske vor der Suche ausgewählt werden, wonach die Ergebnisse sortiert werden sollen, in der Suchergebnistabelle kann man keinen Einfluss auf die Sortierung mehr nehmen.

Ich habe bereits verschiedene Sachen versucht, die Tabellenüberschriften als Link zur Sortierung umzubauen, aber dann werden überhaupt keine Suchergebnisse mehr angezeigt. (und auch keine Fehlermeldung vom Server...)

Das hier ist das script (sieht etwas gewaltig aus wegen der ganzen Formatierungen...)

[klapp]

<?
include("dbconnect.php");

$freqvon = $_POST["freqvon"];
$freqbis = $_POST["freqbis"];
$station = $_POST["station"];
$land = $_POST["itu"];
$sprache = $_POST["D1"];
$datumvon = $_POST["datumvon"];
$datumbis = $_POST["datumbis"];
$uhrzeitvon = $_POST["uhrzeitvon"];
$uhrzeitbis = $_POST["uhrzeitbis"];
$betriebsart = $_POST["betriebsart"];
$username = $_POST["user"];
$empfangsland = $_POST["empfangsland"];
$dienst = $_POST["dienst"];

$sort = $_POST["D2"];

if(!empty($datumvon))
{
$datum = explode(".",$datumvon);
$datumvon = $datum[2]."-".$datum[1]."-".$datum[0];
}
if(!empty($datumbis))
{
$datum = explode(".",$datumbis);
$datumbis = $datum[2]."-".$datum[1]."-".$datum[0];
}
if(!empty($station))
{
$station = ereg_replace("\*","%",$station);
}

$search = "SELECT * FROM qrgdb WHERE";

if(empty($freqvon) AND empty($freqbis))
$search .= " freq != ''";

if(empty($freqvon) AND !empty($freqbis))
$search .= " freq <= ".$freqbis;

if(empty($freqbis) AND !empty($freqvon))
$search .= " freq >= ".$freqvon;

if($freqvon == $freqbis AND !empty($freqvon))
{
$search .= " freq = ".$freqvon;
}
elseif(!empty($freqvon) AND !empty($freqbis))
{
$search .= " (freq >= ".$freqvon." AND freq <= ".$freqbis.")";
}

if(!empty($station))
$search .= " AND station LIKE '".$station."'";

if($land !="Alle")
$search .= " AND itu LIKE '".$land."'";

if($sprache != "Alle")
$search .= " AND lang LIKE '".$sprache."'";

if(!empty($datumvon))
$search .= " AND date >= '".$datumvon."'";

if(!empty($datumbis))
$search .= " AND date <= '".$datumbis."'";

if(!empty($uhrzeitvon))
$s_uhrzeit .= " AND time >= '".$uhrzeitvon."'";

if(!empty($uhrzeitbis))
$s_uhrzeit .= " AND time <= '".$uhrzeitbis."'";

if($uhrzeitbis < $uhrzeitvon AND !empty($uhrzeitvon) AND !empty($uhrzeitbis))
$s_uhrzeit = " AND ((time >= '".$uhrzeitvon."' AND time <= '23:59') OR (time >= '00:00' AND time <= '".$uhrzeitbis."'))";

$search .= $s_uhrzeit;

if($betriebsart != "Alle")
{
$search .= " AND betriebsart LIKE '".$betriebsart."'";
}

if(!empty($username))
$search .= " AND user LIKE '".$username."'";

if($empfangsland !="Alle")
$search .= " AND empfangsland LIKE '".$empfangsland."'";

if($dienst !="Alle")
$search .= " AND dienst LIKE '".$dienst."'";

$search .= " ORDER BY ".$sort;

#echo $search;

$abfrage = mysql_query($search);
?>


<html>

<head>
<meta http-equiv="Content-Language" content="de">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Ihre Suchergebnisse</title>
<style type="text/css">
body, table, td { font-family: Arial; font-size: 10pt; font-color: black; }
</style>
</head>

<body>
<?
if(!empty($abfrage))
{
?>
<p><i><b><font size="3">Your search results<br>
</font></b></i><font size="3">Ihre Suchergebnisse</font></p>
<table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" width="100%" bgcolor="#999999">
<tr>
<td bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Dienst</b></font></td>
<td bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Frequenz</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>UTC</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Datum</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>ITU</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Station</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>
Programmdetails</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Sprache</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>SINPO</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Betriebsart</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>DX ITU</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>User</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Antenne</b></font></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black" bgcolor="#333333" background="http://www.geoo.de/trop/images/style/neo_black/heads.gif">
<font color="#FC4507"><b>Empfänger</b></font></td>
</tr>
<?
while($row = mysql_fetch_object($abfrage))
{
?>
<tr>
<td><? echo $row->dienst; ?></td>
<td><? echo $row->freq; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><?
$time = explode(":",$row->time);
$time = $time[0].":".$time[1];
echo $time;
?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><?
$datum = explode("-",$row->date);
$datum = $datum[2].".".$datum[1].".".$datum[0];
echo $datum;
?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->itu; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->station; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->sonstiges; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->lang; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->SINPO; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->betriebsart; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->empfangsland; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->user; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->antenna; ?></td>
<td style="font-family: Arial; font-size: 10pt; font-color: black"><? echo $row->receiver; ?></td>
</tr>
<?
}
?>
</table>
<?
}
else
{
echo "Ihre Suche brachte keine Ergebnisse!";
}
?>
<br><font color="#FC4507"><br>
</font>
<b>
<a href="suche.php"><font color="#FC4507">Neue Suche</font></a><font color="#FC4507">
</font></b>
</body>
</head>

[/php]

[/klapp]

Bitte entschuldigt diese Anfängerfrage, aber ich zerbreche mir schon 10 Stunden den Kopf darüber...

Deine Variable $sort gibt den Sortierschlüssel an.

Dieser kommt sicher aus der ersten Maske.

Du must also bei Änderung eines Wertes in der zweiten Maske (also neues Feld und neu Abfragen) diese Variable (dannach) überschreiben und deine Abfrage nochmal ausführen.

Überschreiben kannst du durch eine ganz einfach if-Abfrage.

*Ist nicht ganz doll schwer*

Das klingt einleuchtend. Kann das der Grund sein warum ich dann "Ihre suche brachte keine Ergebnisse" erhalte?

$sort kommt aus der ersten Maske, das hast du genau richtig erkannt.

Wie schaut denn diese if-Abfrage aus, die beim Sortieren in der Ergebnislste die Voreinstellung eliminiert?

Vielleicht baust du eine neues Dropdownfeld ein, nennen wir es $sort2.

Als Standardwert könnte dort drin stehen 'keine Auswahl'.

Weitere Werte sind diejenigen, nach denen du sortieren möchtest.

Wenn d dort eine andere Auswahl triffst, rufst du entsprechend die gleiche Seite nochmals auf (genauso, wie du von der ersten zur zweiten Seite gekommen bist - diesmal nur von der zweiten Seite zur zweiten Seiten)

Dann brauchst du beim neuen Aufbau der Seite die Unterteilung:


if ($sort2!='keine Auswahl'){

   $sort=$sort2;  //Ueberschreibung der Sortierung

}

an der richitgen Stelle. Dette könnte klappen.

ich habe jetzt hinzugefügt:



$sort = $_POST["D2"]; //DAS STAND SCHON DA
$sort2 = $_POST["sort2"]; //NEU HINZU, sort2 heißt auch das dropdown-Feld


if ($sort2!='keine Auswahl'){
$sort=$sort2; //Ueberschreibung der Sortierung
}
[/php]

und etwas weiter unten kommt dann noch das Dropdown:

[code] <form method="POST" action="search.php"> <p><select size="1" name="sort2"> <option value="itu">ITU</option> <option>keine Auswahl</option> </select><input type="submit" value="Absenden" name="B1"></p> </form> [/code]

Leider bekomme ich, auch schon bei der ersten Suche ohne irgendetwas zu sortieren, kein einziges Suchergebnis mehr angezeigt... (Bitte geben Sie Ihre Daten ein)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.