简体   繁体   中英

Passing PHP Next Page Variables

I want to pass the php variable to the next page.

I tried many things, but I did not succeed. Here is the attached case I tried.

index code

<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>

next code

<?php 
    echo $name;
?>

url has been changed to a variable, but a blank screen is displayed. (Variables were not passed to the next page.)

Try this --

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM