如何在点击php时强制刷新?
我有两个html按钮,分别是back和next。 如果我单击这些按钮,变量将递增或递减。 此变量将被发送到function.php,其中有一条sql语句。 声明如下:如何在点击php时强制刷新?,php,html,ajax,jss,Php,Html,Ajax,Jss,我有两个html按钮,分别是back和next。 如果我单击这些按钮,变量将递增或递减。 此变量将被发送到function.php,其中有一条sql语句。 声明如下: select * from x where dimension is = value 如何刷新页面以从查询中显示新表 这就是我的php: function tbl_showPage($page){ global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;
select * from x where dimension is = value
如何刷新页面以从查询中显示新表
这就是我的php:
function tbl_showPage($page){
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($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'].'">';
}
也许我的var没有通过也许
javascript函数如下所示:
var-ki=kd=1;
功能增强
{
ki++;
$.ajax{
类型:POST,,
url:'inc/functions.php',
数据:{page:ki},
成功:functiondata{
控制台日志数据;
}
};
window.location.reload;
}
功能减退
{
kd-;
$.ajax{
类型:POST,,
url:'inc/functions.php',
数据:{page:kd},
成功:functiondata{
控制台日志数据;
}
};
window.location.reload;
}
这里似乎混合了PHP和javascript 你的按钮上有onClick功能吗?如果您这样做了,并且调用了javascript函数,则只需添加window.location.reload;在javascript函数的底部重新加载页面
提示:在你的帖子上使用编辑功能并添加与你的问题相关的代码,这样就更容易获得帮助 用JavaScript制作很容易
function myFunction() {
window.location.reload();
}
然后你只要把这个功能添加到你的按钮上
<button class="myButton" onclick=myFunction()">Click to reload</button>
从url或ajax调用function.php时可能存在重复?