通过url将变量传递到下一页

问题描述:

在这里,我正在计算配置文件所有者所关注的人数,并且输出数字是链接以打开新页面,所有被跟踪的人都将被显示,计数效果良好并给出正在跟踪的人数,但现在完成我的下一页说following.php其中所有被跟踪的人将被显示我需要通过变量$id到我想要使用url方法的网页,请帮助我这一点。通过url将变量传递到下一页

<?php 
$checkfollowing =$db->prepare("SELECT * FROM follow_user WHERE uid_fk=:id"); 
$checkfollowing->execute(array(':id'=>$id)); 
$count = $checkfollowing->rowCount(); ?> 
<a href='following.php' style='text-decoration:none;margin-left:40px;'><?php print $count; ?></a> 

您可以通过url传递值,并使用$_GET方法获取其他页面上的值。 检查下面的代码。

<a href='following.php?id=<?php echo $id ; ?>' style='text-decoration:none;margin-left:40px;'><?php print $count; ?></a> 

你可以通过url传递一个变量,通过在你的url结尾指定你的变量。像这样

<a href='following.php?count=<?php echo $count; ?>' style='text-decoration:none;margin-left:40px;'><?php print $count; ?></a> 

<a href='following.php?id=<?php echo $id; ?>' style='text-decoration:none;margin-left:40px;'><?php print $count; ?></a>