I got a function.php which is in inc/function. This function contains a table. This table is generated in an MySQL statement.
My idea is quite easy - the user is able to go through the table with a next button and a back button.
Here is my code:
<div class="container-fluid">
<form action="fda.php" method="post">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<p>Bitte beantworten Sie die folgenden Fragen:</p>
<table class="table table-striped">
<thead>
<tr>
<th>Nr.</th>
<th width="250">Frage</th>
<?php tbl_description() ?>
</tr>
</thead>
<tbody>
<?php tbl_showPage() ?>
</tbody>
</table>
</div>
<div class="col-md-6 col-md-offset-3 text-center">
<form action="functions.php" method="post">
<input type="submit" name="back" value="Zurück" id="back" class="btn btn-default">
<input type="submit" name="go" value="Weiter" id="go" class="btn btn-default">
<!--<input type="submit" value="FDA auswerten" class="btn btn-default">-->
</div>
</div>
</form>
</div>
this is the part from the fda.php file! Everything is working cool except the increase of the mysql statement which is in the function.php. While clicking on next the statement should be "refreshed" and show me the 2nd page of the table. Its like an questionaire.
This is the code of the function php.
function tbl_showPage(){
global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;
$connection=mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
mysqli_select_db($connection, $mysqldb) or die("Konnte die Datenbank nicht waehlen.");
if(isset($_POST['go']))
{
$page++;
}
elseif($_POST['back'])
{
$page--;
}
//if(isset($page)){
if($page<1)
{
$sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1' && dimension='1'";
}
elseif($page>9)
{
$sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1' && dimension='9'";
}
else
{
$sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1' && dimension=$page";
}
//}
$quest_query = mysqli_query($connection, $sql_tbl_questions) or die("Anfrage nicht erfolgreich");
$i = 0;
while ($question = mysqli_fetch_array($quest_query)) {
$i++;
echo '<tr>';
echo '<th>'.$i.'</th>';
echo '<th>'.$question['question'].'</th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="0" required></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="2.5"></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="5"></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="7.5"></th>';
echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="10"></th>';
echo '</tr>';
$dimensions = $question['dimension'];
}
echo '<tr>';
echo '<th></th>';
echo '<th>Kommentar/Ihre Anmerkung</th>';
echo '<th class="text-center" colspan=5><textarea rows=3 cols=50 name="Kommentar"></textarea></th>';
echo '</tr>';
echo '<input type="hidden" name="gesamt" value="'.$i.'">';
echo '<input type="hidden" name="dimensions" value="'.$dimensions.'">';
echo '<input type="hidden" name="size" value="'.$_POST['size'].'">';
echo '<input type="hidden" name="branche" value="'.$_POST['branche'].'">';
}
Maybe I am missing something? I really hope someone can help me!
</div>