Stand 17.02.2023
This commit is contained in:
163
survey/index.php
Normal file
163
survey/index.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
## INDEX gegen DB
|
||||
if(!isset($_SESSION)) { session_start(); }
|
||||
#$_SESSION['sessionid'] = session_id();
|
||||
|
||||
|
||||
include_once '../classes/TestProjektSmarty.class_subdir.php';
|
||||
#require_once("../config.inc.php");
|
||||
require_once("../config/datenbankanbindung.php");
|
||||
$smarty = new SmartyAdmin();
|
||||
$templatename = substr(basename($_SERVER['PHP_SELF']),0,-3)."html";
|
||||
require_once "../language/german.inc.php";
|
||||
|
||||
|
||||
$action = $_GET['action'];
|
||||
if($action == ''){
|
||||
$db = dbconnect();
|
||||
|
||||
|
||||
// Datendefinition
|
||||
$start = (isset($_POST['start'])) ? abs((int)$_POST['start']) : 0;
|
||||
$ip = $_SERVER["REMOTE_ADDR"];
|
||||
$limit = 1; // Fragen pro Seite
|
||||
|
||||
#############################################################################
|
||||
$umid=1;
|
||||
#############################################################################
|
||||
|
||||
####################### Speichern der Antworten #############################
|
||||
if(isset($_POST['save'])){
|
||||
$frage = $_POST['save'];
|
||||
$result_multiple = $db->query("SELECT multiple
|
||||
FROM jumi_umfragen_fragen
|
||||
WHERE ufid = $frage;");
|
||||
$row_multiple = $result_multiple->fetch_array();
|
||||
if($row_multiple['multiple'] == '0'){
|
||||
echo "Antwort: $_POST[antwort]<br>";
|
||||
}
|
||||
if($row_multiple['multiple'] == '1'){
|
||||
$query = "SELECT uaid
|
||||
FROM jumi_umfragen_antworten
|
||||
WHERE ufid = $frage
|
||||
ORDER BY ufid ASC";
|
||||
$result = $db->query( $query);
|
||||
while ($row = $result->fetch_array()){
|
||||
$antwort = $_POST['antwort_'.$row['uaid']];
|
||||
if($antwort != ''){
|
||||
echo "Antwort: $antwort<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
####################### Ausgabe der Fragen #####################################
|
||||
|
||||
$last = floor($total/$limit)*$limit; //Sprungziel zur letzten Seite BSP abrunden(1954/13)*13 ==> 150*13=1950 Sprungmarke auf Zeile 1950, 4 DS werden angezeigt
|
||||
$akt = round((($start-$limit)/$limit+2),0);
|
||||
|
||||
$result0 = $db->query("SELECT headline
|
||||
FROM jumi_umfragen
|
||||
WHERE umid = $umid;");
|
||||
$row0 = $result0->fetch_array();
|
||||
$smarty->assign('umfrage_headline', $row0['headline']);
|
||||
|
||||
$result = $db->query("SELECT count(*)-1 Anz_limit, round(100/count(*)*$akt,1) progress, count(*) total
|
||||
FROM jumi_umfragen_fragen
|
||||
WHERE umid = $umid;");
|
||||
$row = $result->fetch_array();
|
||||
$smarty->assign('umfrage_progress', $row['progress']);
|
||||
$total = $row['total'];
|
||||
|
||||
#$show = ceil($total/$limit); //Seitenzahlen aufrunden
|
||||
|
||||
if(isset($_POST['start'])){
|
||||
echo "hier|$total|$limit|$start";
|
||||
$start = ($_POST['start'] >= $total) ? $total - $limit : $start;
|
||||
}else{
|
||||
|
||||
$start = 0;
|
||||
}
|
||||
echo"
|
||||
<hr>
|
||||
$start
|
||||
<hr>
|
||||
";
|
||||
|
||||
#echo "$row[Anz_limit]<br>";
|
||||
|
||||
// Datenbankabfrage ausführen.
|
||||
$query = "SELECT ufid, frage, multiple
|
||||
FROM jumi_umfragen_fragen
|
||||
WHERE umid = 1
|
||||
ORDER BY ufid ASC
|
||||
LIMIT ".$start.",1";
|
||||
$result = $db->query( $query);
|
||||
|
||||
// Ergebnisse lesen und an den Client ausgeben
|
||||
|
||||
while ($row = $result->fetch_array()){
|
||||
$value2 = '';
|
||||
|
||||
$query2 = "SELECT uaid, antwort
|
||||
FROM jumi_umfragen_antworten
|
||||
WHERE ufid = $row[ufid]
|
||||
ORDER BY userorder ASC
|
||||
";
|
||||
|
||||
$result2 = $db->query( $query2)
|
||||
or die ("Cannot execute query2");
|
||||
$ln2 = 0;
|
||||
while ($row2 = $result2->fetch_array()){
|
||||
$inner1[$ln2]['uaid'] = $row2['uaid'];
|
||||
$inner1[$ln2]['antwort'] = $row2['antwort'];
|
||||
$value2 = $inner1;
|
||||
$ln2++;
|
||||
}
|
||||
$row['inner'] = $value2;
|
||||
|
||||
|
||||
$table_data[] = $row;
|
||||
}
|
||||
$smarty->assign('table_data', $table_data);
|
||||
|
||||
#echo"<pre>";
|
||||
#print_r($table_data);
|
||||
#echo"</pre>";
|
||||
|
||||
// Zurück- und Vorblättern
|
||||
if ($start > 0){
|
||||
$newStart = ($start - $limit < 0) ? 0 : ($start-$limit); // wenn $start-$limit kleiner 0 dann $newstart=0 sonst $start-$limit
|
||||
$smarty->assign('umfrage_start0', "1");
|
||||
$smarty->assign('umfrage_start_newstart', "$newStart");
|
||||
}else{
|
||||
$smarty->assign('umfrage_start0', "2");
|
||||
}
|
||||
|
||||
|
||||
if ($start + $limit < $total){
|
||||
$newStart = $start + $limit;
|
||||
$smarty->assign('umfrage_end0', "1");
|
||||
$smarty->assign('umfrage_end_newstart', "$newStart");
|
||||
$smarty->assign('umfrage_end_last', "$last");
|
||||
}else{
|
||||
$smarty->assign('umfrage_end0', "2");
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign('action', "$action");
|
||||
$smarty->display("modern/survey/$templatename");
|
||||
?>
|
Reference in New Issue
Block a user