gpt4 book ai didi

javascript - 传递 PHP 下一页变量

转载 作者:行者123 更新时间:2023-11-29 16:00:05 24 4
gpt4 key购买 nike

我想将 php 变量传递到下一页。

我尝试了很多事情,但没有成功。这是我尝试过的附件案例。

索引代码

<script>
<?php
$con = mysqli_connect($db_host,$db_user,$db_passwd,$db_name);

mysqli_set_charset($con, "utf8");

$result = mysqli_query($con, "select * from StoreTable");

$n = 1;
while($row = mysqli_fetch_array($result)){
$name = $row['name'];
?>
positions_1.push({ content:
'<div class="wrap">' +
' <div><a href="next.php?name=<?= $name; ?>" target="_blank" class="link">next page</a></div>' +
'</div>'
});
<?
$n++;
}
?>
</script>

下一个代码

<?php 
echo $name;
?>

url 已更改为变量,但显示空白屏幕。 (变量未传递到下一页。)

最佳答案

试试这个——

<script>
<?php
$con = mysqli_connect($db_host,$db_user,$db_passwd,$db_name);

mysqli_set_charset($con, "utf8");

$result = mysqli_query($con, "select * from StoreTable");

$n = 1;
while($row = mysqli_fetch_array($result)){
$name = $row['name'];
?>
positions_1.push({ content:
'<div class="wrap">' +
' <div><a href="next.php?name=<?php echo $name; ?>" target="_blank" class="link">next page</a></div>' +
'</div>'
});
<?
$n++;
}
?>
</script>

关于javascript - 传递 PHP 下一页变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56254949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com