Fragebogen/suche.php
2024-02-21 13:18:33 +01:00

375 lines
16 KiB
PHP
Executable File

<?PHP
include("aespa/datenbankanbindung.php"); // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
if ($_COOKIE["uid1"] == ""){ include("kurs/anmeldefehler.php"); exit;} //Wenn man nicht angemeldet ist soll man nichts ausw&auml;hlen k&ouml;nnen
$uid1=$_COOKIE["uid1"];
if (isset($_GET['action']))
$action = $_GET['action'];
else
$action = "";
switch($action){
default:
echo "
<html>
<head>
<title>Suche zum Auslandspraktikum</title>
<style>
<!--
h2
{margin-bottom:.0001pt;
text-align:center;
page-break-after:avoid;
font-size:20.0pt;
font-family:Arial;
margin-left:0cm; margin-right:0cm; margin-top:0cm}
h1
{margin-bottom:.0001pt;
page-break-after:avoid;
font-size:12.0pt;
font-family:Arial;
margin-left:0cm; margin-right:0cm; margin-top:0cm}
select{
width:250px;
}
-->
</style>
<script src='jquery-3.4.1.min.js'></script>
<script type='text/javascript'>
function fetch_select(){
var kontinent = document.getElementById('kontinent').options[document.getElementById('kontinent').options.selectedIndex].value;
$.ajax({
type: 'POST',
url: 'get_land.php',
data: {
'function': 'fetch_select',
'kontinent': kontinent
},
success: function(result) { //we got the response
document.getElementById('land').innerHTML=result;
},
error: function(xhr, status, exception) {
console.log(xhr);
}
});
}
</script>
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
</head>
<body onload=\"if(document.auswert)document.auswert.dhtmlgoodies_country.focus();if(document.auswert)document.auswert.uberschrift.focus();return false;\">
<h2>Suche zum Auslandspraktikum</h2>
<p align='center'>
<img border='0' src='images/aespa_logo.jpg' width='493' height='132' align='center'></p>
<p align='center'>&nbsp;</p>
<form action=";echo $_SERVER['PHP_SELF'] . "?action=auswertung";echo" method=\"POST\" name=\"auswert\">
<div align='center'>
<table border='0' width='40%' id='table2' style='border-collapse: collapse' bgcolor='#EAEAEA'>
<tr>
<td colspan='2' style='border-left-style: solid; border-left-width: 2px; border-right-style: solid; border-right-width: 2px; border-top-style: solid; border-top-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>
&nbsp;
</td>
</tr>
<tr>
<td width='30%' style='border-left-style: solid; border-left-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>
Kontinent </td>
<td width='70%' style='border-right-style: solid; border-right-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>";
$db = dbconnect();
$query2 = "SELECT distinct a.kid, a.kontinent
FROM aesp_kontinent a, aesp_bewerbung b
WHERE a.kid = b.kontinent
ORDER BY kontinent ASC";
$result2 = $db->query ($query2)
or die ("Cannot execute query");
echo "<select id='kontinent' name='kontinent' onchange='fetch_select();'>
<option value=''>Select</option>";
# echo "<option value='%'";if($row3['kontinent'] == '%'){echo " selected";} echo">Alle&nbsp;&nbsp;&nbsp;</option>\n";
while ($row2 = $result2->fetch_array()){
echo "<option value='$row2[kid]'";if(isset($row2['kid']) AND isset($row3['kontinent']) AND $row2['kid'] == $row3['kontinent']){echo " selected";} echo">".$row2['kontinent']."&nbsp;&nbsp;&nbsp;</option>\n";
}
echo"
</td>
</tr>
<tr>
<td width='30%' style='border-left-style: solid; border-left-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>
Land </td>
<td width='70%' style='border-right-style: solid; border-right-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>
<select id='land' name='land'>
</select>
</p>
</td>
</tr>
<tr>
<td width='30%' style='border-left-style: solid; border-left-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>
ab Jahrgang
</td>
<td width='70%' style='border-right-style: solid; border-right-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>";
$query2 = "SELECT distinct DATE_Format(zeitraum_von, '%Y') jahrgang
FROM aesp_allgemein
WHERE DATE_Format(zeitraum_von, '%Y') != '0000'
ORDER BY jahrgang DESC
";
$result2 = $db->query ($query2)
or die ("Cannot execute query");
echo "<select size=\"1\" name=\"jahrgang\">";
# echo "<option value='%'";if($row3[kontinent] == '%'){echo " selected";} echo">Alle&nbsp;&nbsp;&nbsp;</option>\n";
while ($row2 = $result2->fetch_array()){
echo "<option value='$row2[jahrgang]'"; if(isset($row3['jahrgang']) AND isset($row2['jahrgang']) AND $row3['jahrgang'] == $row2['jahrgang']){echo " selected"; } echo">$row2[jahrgang]</option>\n";
}
echo "</select>
</p>
</td>
</tr>
<tr>
<td colspan='2' style='border-left-style: solid; border-left-width: 2px; border-right-style: solid; border-right-width: 2px;>
<p style='margin-left: 3px; margin-right: 3px'>
&nbsp;
</td>
</tr>
<tr>
<td colspan=2 align='center' style='border-left-style: solid; border-left-width: 2px; border-right-style: solid; border-right-width: 2px''>
<input type=\"submit\" value=\"Suche\" name=\"B1\" size=\"20\"></form>
</td
</tr>
<tr>
<td width='30%' style='border-left-style: solid; border-left-width: 2px; border-bottom-style: solid; border-bottom-width: 2px'>
<p style='margin-left: 3px; margin-right: 3px'>&nbsp;</td>
<td width='70%' style='border-bottom-style: solid; border-bottom-width: 2px; border-right-style:solid; border-right-width:2px'>
<p style='margin-left: 3px; margin-right: 3px'>
&nbsp;</td>
</tr>
</table>
<br>
<br>
<br>
<div align='center'> Es werden nur verfügbare Kontinente / Länder / Jahrgänge angezeigt!</div>
</body>
</html>";
break;
case "auswertung":
if(!isset($_POST['kontinent'])){
$kontinent=$_GET['kontinent'];
}else{
$kontinent=$_POST['kontinent'];
}
if(!isset($_POST['land'])){
$land=$_GET['land'];
}else{
$land=$_POST['land'];
}
if(!isset($_POST['jahrgang'])){
$jahrgang=$_GET['jahrgang'];
}else{
$jahrgang=$_POST['jahrgang'];
}
if(isset($_GET["sort"])){
$sort = $_GET["sort"];
}else{
$sort = 'kontinent';
}
if(isset($_GET["option"])){
$option = $_GET["option"];
}else{
$option = 'DESC';
}
if($option == 'ASC'){
$option = 'DESC';
}else{
$option = 'ASC';
}
## Anzahl der Treffer ermitteln
$db = dbconnect();
$result_anz = $db->query("SELECT count(*) anz_treffer
FROM aesp_bewerbung a, aesp_allgemein b
WHERE a.uid = b.uid
AND a.kontinent LIKE '$kontinent'
AND a.land LIKE '$land'
AND DATE_Format(zeitraum_von, '%Y') >= '$jahrgang'");
$row_anz = $result_anz->fetch_array();
echo "
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
<title>Statistik</title>
<style><!--
.sl,.r{font-weight:normal;margin:0;display:inline}
.r{font-size:1em}
.g{margin-top:1em;margin-bottom:1em}
.a,.a:link{color:green}
body,td,div,.p,a{font-family:arial,sans-serif}
--></style>
</head>
<body>
<table align=\"center\" border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"95%\" id=\"table1\">
<tr>
<td>
<div align=\"center\">
<table valign=\"top\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" border=\"0\">
<tr>
<td width=\"10\" background=\"images/box_e1.gif\">
<img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
<td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_top.gif\" valign=\"top\">
<img height=\"10\" src=\"images/blank.gif\" width=\"1\"><br>
<font class=\"hd\">Suchergebnisse</font><br>
<span class=\"sh\">Treffer: $row_anz[anz_treffer]</span><br>
<img height=\"5\" src=\"images/blank.gif\" width=\"1\"></td>
<td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e2.gif\">
<img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
</tr>
<tr>
<td width=\"1%\" background=\"images/box_l.gif\">
<img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
<td>
<table valign=\"top\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\" id=\"AutoNumber1\">
<tr>
<td>";
if($sort == 'kontinent'){
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=kontinent&option=$option><b>Kontinent</b></a></font>";
}else{
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=kontinent&option=$option>Kontinent</a></font>";
}
echo "
</td>
<td>";
if($sort == 'land'){
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=land&option=$option><b>Land</b></a></font>";
}else{
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=land&option=$option>Land</a></font>";
}
echo "
</td>
<td>";
if($sort == 'stadt'){
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=stadt&option=$option><b>Stadt</b></a></font>";
}else{
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=stadt&option=$option>Stadt</a></font>";
}
echo "
</td>
<td>";
if($sort == 'zeitraum_von'){
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=zeitraum_von&option=$option><b>Zeitraum ab</b></a></font>";
}else{
echo "<font size=\"2\"><a href=$_SERVER[PHP_SELF]?action=auswertung&kontinent=$kontinent&land=$land&jahrgang=$jahrgang&sort=zeitraum_von&option=$option>Zeitraum ab</a></font>";
}
echo "
</td>
<td>
Link
</td>
</tr>
";
$db = dbconnect();
$query = "SELECT a.uid, a.kontinent, a.land, a.stadt, date_format(zeitraum_von, '%d.%m.%Y') datum, zeitraum_von
FROM aesp_bewerbung a, aesp_allgemein b
WHERE a.uid = b.uid
AND a.kontinent LIKE '$kontinent'
AND a.land LIKE '$land'
AND DATE_Format(zeitraum_von, '%Y') >= '$jahrgang'
ORDER BY $sort $option
";
$result = $db->query($query)
or die ("Cannot execute query");
while ($row = $result->fetch_array()){
$result_kont = $db->query("SELECT kontinent
FROM aesp_kontinent
WHERE kid='$row[kontinent]'");
$row_kont = $result_kont->fetch_array();
$result_land = $db->query("SELECT land
FROM aesp_land
WHERE lid='$row[land]'");
$row_land = $result_land->fetch_array();
echo "
<tr>
<td>
$row_kont[kontinent]
</td>
<td>
$row_land[land]
</td>
<td>
$row[stadt]
</td>
<td>
$row[datum]
</td>
<td>
<a href='ansicht.php?uid_user=$row[uid]'>Ansehen</a>
</td>
</tr>
";
}
echo"
</table>
</td>
<td width=\"1%\" background=\"images/box_r.gif\">
<img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
</tr>
<tr>
<td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"images/box_e3.gif\">
<img height=\"16\" src=\"images/blank.gif\" width=\"22\"></td>
<td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_bottom.gif\">
<img height=\"16\" src=\"images/blank.gif\" width=\"8\"></td>
<td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e4.gif\">
<img height=\"16\" src=\"images/blank.gif\" width=\"22\"> </td>
</tr>
</table>
</div>
<p align=\"center\"><a href=\"javascript:history.back()\">
<img border=\"0\" src=\"images/zurueck.gif\" width=\"77\" height=\"22\"></a>
</td>
</tr>
</table>
</body>
</html>
";
}
?>