我想将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已更改为变量,但显示空白屏幕。 (变量未传递到下一页。)
答案 0 :(得分:0)
尝试一下-
<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>